MCPcopy Create free account
hub / github.com/bytecodealliance/wit-bindgen / run_command

Method run_command

crates/test/src/lib.rs:1044–1077  ·  view source on GitHub ↗

Helper to execute an external process and generate a helpful error message on failure.

(&self, cmd: &mut Command)

Source from the content-addressed store, hash-verified

1042 /// Helper to execute an external process and generate a helpful error
1043 /// message on failure.
1044 fn run_command(&self, cmd: &mut Command) -> Result<()> {
1045 if self.opts.inherit_stderr {
1046 cmd.stderr(Stdio::inherit());
1047 }
1048 let output = cmd
1049 .output()
1050 .with_context(|| format!("failed to spawn {cmd:?}"))?;
1051 if output.status.success() {
1052 return Ok(());
1053 }
1054
1055 let mut error = format!(
1056 "\
1057command execution failed
1058command: {cmd:?}
1059status: {}",
1060 output.status,
1061 );
1062
1063 if !output.stdout.is_empty() {
1064 error.push_str(&format!(
1065 "\nstdout:\n {}",
1066 String::from_utf8_lossy(&output.stdout).replace("\n", "\n ")
1067 ));
1068 }
1069 if !output.stderr.is_empty() {
1070 error.push_str(&format!(
1071 "\nstderr:\n {}",
1072 String::from_utf8_lossy(&output.stderr).replace("\n", "\n ")
1073 ));
1074 }
1075
1076 bail!("{error}")
1077 }
1078
1079 /// Converts the WASIp1 module at `p1` to a component using the information
1080 /// stored within `compile`.

Callers 15

prepareMethod · 0.80
compileMethod · 0.80
verifyMethod · 0.80
prepareMethod · 0.80
compileMethod · 0.80
verifyMethod · 0.80
prepareFunction · 0.80
compileFunction · 0.80
verifyFunction · 0.80
runtime_testMethod · 0.80
generate_bindingsMethod · 0.80
prepareMethod · 0.80

Calls 2

is_emptyMethod · 0.45
push_strMethod · 0.45

Tested by

no test coverage detected