Auto merge of #2391 - RalfJung:stderr, r=oli-obk

on an error, always print the unnormalized stderr

Currently we skip this if a stderr diff was printed, but the stderr diff is normalized, so e.g. one cannot learn line numbers from it.

Is there a way to get the diff to only print the parts the differ, like a usual `diff -u`? Currently it always seems to print the full output, so with a long stderr we now get doubly long test results even if the diff is actually rather small.
This commit is contained in:
bors 2022-07-20 12:39:21 +00:00
commit 0844e46049

View File

@ -164,15 +164,14 @@ pub fn run_tests(config: Config) -> Result<()> {
if !failures.is_empty() { if !failures.is_empty() {
for (path, miri, revision, errors, stderr) in &failures { for (path, miri, revision, errors, stderr) in &failures {
eprintln!(); eprintln!();
eprint!("{}", path.display().to_string().underline()); eprint!("{}", path.display().to_string().underline().bold());
if !revision.is_empty() { if !revision.is_empty() {
eprint!(" (revision `{}`)", revision); eprint!(" (revision `{}`)", revision);
} }
eprint!(" {}", "FAILED".red()); eprint!(" {}", "FAILED:".red().bold());
eprintln!(); eprintln!();
eprintln!("command: {:?}", miri); eprintln!("command: {:?}", miri);
eprintln!(); eprintln!();
let mut dump_stderr = true;
for error in errors { for error in errors {
match error { match error {
Error::ExitStatus(mode, exit_status) => eprintln!("{mode:?} got {exit_status}"), Error::ExitStatus(mode, exit_status) => eprintln!("{mode:?} got {exit_status}"),
@ -194,9 +193,6 @@ pub fn run_tests(config: Config) -> Result<()> {
Error::PatternFoundInPassTest => Error::PatternFoundInPassTest =>
eprintln!("{}", "error pattern found in success test".red()), eprintln!("{}", "error pattern found in success test".red()),
Error::OutputDiffers { path, actual, expected } => { Error::OutputDiffers { path, actual, expected } => {
if path.extension().unwrap() == "stderr" {
dump_stderr = false;
}
eprintln!("actual output differed from expected {}", path.display()); eprintln!("actual output differed from expected {}", path.display());
eprintln!("{}", pretty_assertions::StrComparison::new(expected, actual)); eprintln!("{}", pretty_assertions::StrComparison::new(expected, actual));
eprintln!() eprintln!()
@ -223,14 +219,11 @@ pub fn run_tests(config: Config) -> Result<()> {
} }
eprintln!(); eprintln!();
} }
// Unless we already dumped the stderr via an OutputDiffers diff, let's dump it here. eprintln!("full stderr:");
if dump_stderr { eprintln!("{}", stderr);
eprintln!("actual stderr:"); eprintln!();
eprintln!("{}", stderr);
eprintln!();
}
} }
eprintln!("{}", "failures:".red().underline()); eprintln!("{}", "FAILURES:".red().underline().bold());
for (path, _miri, _revision, _errors, _stderr) in &failures { for (path, _miri, _revision, _errors, _stderr) in &failures {
eprintln!(" {}", path.display()); eprintln!(" {}", path.display());
} }