Skip to content

Commit 4330784

Browse files
committed
Print sterr better when tests fail
1 parent 385d909 commit 4330784

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

tests/common/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,16 @@ macro_rules! write_range_to_hb {
146146
pub(crate) use write_range_to_hb;
147147

148148
pub fn check_cmd_output(out: Output) -> Result<Output> {
149-
eprint!("{}", String::from_utf8_lossy(&out.stdout));
150149
if out.status.code() != Some(0) {
150+
if !out.stdout.is_empty() {
151+
eprintln!("stdout:\n{}", String::from_utf8_lossy(&out.stdout));
152+
}
153+
if !out.stderr.is_empty() {
154+
eprintln!("stderr:\n{}", String::from_utf8_lossy(&out.stderr));
155+
}
151156
return Err(Box::new(Error::TestError(format!(
152-
"comand output status was not zero. Got:\nstdout: {}\nstderr: {}",
153-
String::from_utf8_lossy(&out.stdout),
154-
String::from_utf8_lossy(&out.stderr),
157+
"command output status was not zero. Got:{:?}",
158+
out.status.code()
155159
))));
156160
}
157161
Ok(out)

0 commit comments

Comments
 (0)