Skip to content

Commit

Permalink
tests: Improve integration test output on assertion failure
Browse files Browse the repository at this point in the history
The child process output was only being printed on process failure, not
later test assertions. Printing the output unconditionally allows it to
be seen on any failure without noisy --nocapture.

Signed-off-by: Lann Martin <[email protected]>
  • Loading branch information
lann committed Mar 7, 2023
1 parent 276e570 commit 1decdd2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -845,17 +845,20 @@ mod integration_tests {
.collect::<Vec<String>>()
.join(" "),
);

cmd.env("RUST_LOG", "spin_cli=warn");
if let Some(envs) = envs {
for (k, v) in envs {
cmd.env(k, v);
}
}

let output = cmd.output()?;
println!("STDOUT:\n{}", String::from_utf8_lossy(&output.stdout));
println!("STDERR:\n{}", String::from_utf8_lossy(&output.stderr));

let code = output.status.code().expect("should have status code");
if code != 0 {
println!("{:#?}", std::str::from_utf8(&output.stderr)?);
println!("{:#?}", std::str::from_utf8(&output.stdout)?);
panic!("command `{:?}` exited with code {}", cmd, code);
}

Expand Down

0 comments on commit 1decdd2

Please sign in to comment.