Skip to content

Commit

Permalink
Auto merge of rust-lang#2232 - rust-lang:gesundheit, r=oli-obk
Browse files Browse the repository at this point in the history
Always show stderr on test failure.

fixes rust-lang#2224

I overengineered the original thing to the point where it became fragile. Let's just always print stderr, unless it was already printed
  • Loading branch information
bors committed Jun 13, 2022
2 parents 9642534 + 0689f36 commit 4c1f50b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions ui_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,7 @@ pub fn run_tests(config: Config) {
eprintln!();
eprintln!("command: {:?}", miri);
eprintln!();
// `None` means never dump, as we already dumped it for an `OutputDiffers`
// `Some(false)` means there's no reason to dump, as all errors are independent of the stderr
// `Some(true)` means that there was a pattern in the .rs file that was not found in the output.
let mut dump_stderr = Some(false);
let mut dump_stderr = true;
for error in errors {
match error {
Error::ExitStatus(mode, exit_status) => eprintln!("{mode:?} got {exit_status}"),
Expand All @@ -160,7 +157,6 @@ pub fn run_tests(config: Config) {
"expected because of pattern here: {}:{definition_line}",
path.display().to_string().bold()
);
dump_stderr = dump_stderr.map(|_| true);
}
Error::NoPatternsFound => {
eprintln!("{}", "no error patterns found in failure test".red());
Expand All @@ -169,7 +165,7 @@ pub fn run_tests(config: Config) {
eprintln!("{}", "error pattern found in success test".red()),
Error::OutputDiffers { path, actual, expected } => {
if path.extension().unwrap() == "stderr" {
dump_stderr = None;
dump_stderr = false;
}
eprintln!("actual output differed from expected {}", path.display());
eprintln!("{}", pretty_assertions::StrComparison::new(expected, actual));
Expand Down Expand Up @@ -203,7 +199,8 @@ pub fn run_tests(config: Config) {
}
eprintln!();
}
if let Some(true) = dump_stderr {
// Unless we already dumped the stderr via an OutputDiffers diff, let's dump it here.
if dump_stderr {
eprintln!("actual stderr:");
eprintln!("{}", stderr);
eprintln!();
Expand Down

0 comments on commit 4c1f50b

Please sign in to comment.