From 0689f36a5528875d3a0c467a327becbed961e6a6 Mon Sep 17 00:00:00 2001 From: Oli Scherer Date: Mon, 13 Jun 2022 08:55:34 +0000 Subject: [PATCH] Always show stderr on test failure. --- ui_test/src/lib.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ui_test/src/lib.rs b/ui_test/src/lib.rs index caefee1992ed8..7f9eb48e05f9e 100644 --- a/ui_test/src/lib.rs +++ b/ui_test/src/lib.rs @@ -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}"), @@ -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()); @@ -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)); @@ -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!();