Print out stderr if CLI test fails

This commit is contained in:
Brian Carroll 2022-09-26 09:05:13 +01:00
parent bad993a957
commit 1a5ef05585
No known key found for this signature in database
GPG Key ID: 9CF4E3BF9C4722C7
2 changed files with 8 additions and 2 deletions

View File

@ -233,7 +233,13 @@ mod cli_run {
);
}
assert!(out.status.success());
if !out.status.success() {
// We don't need stdout, Cargo prints it for us.
panic!(
"Example program exited with status {:?}\nstderr was:\n{:#?}",
out.status, out.stderr
);
}
}
}

View File

@ -136,7 +136,7 @@ int main() {
}
// Write to stdout
if (write(1, str_bytes, str_len) >= 0) {
if (write(STDOUT_FILENO, str_bytes, str_len) >= 0) {
// Writing succeeded!
return 0;
} else {