Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 4c1f50b

Browse files
committed
Auto merge of rust-lang#2232 - rust-lang:gesundheit, r=oli-obk
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
2 parents 9642534 + 0689f36 commit 4c1f50b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

ui_test/src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ pub fn run_tests(config: Config) {
147147
eprintln!();
148148
eprintln!("command: {:?}", miri);
149149
eprintln!();
150-
// `None` means never dump, as we already dumped it for an `OutputDiffers`
151-
// `Some(false)` means there's no reason to dump, as all errors are independent of the stderr
152-
// `Some(true)` means that there was a pattern in the .rs file that was not found in the output.
153-
let mut dump_stderr = Some(false);
150+
let mut dump_stderr = true;
154151
for error in errors {
155152
match error {
156153
Error::ExitStatus(mode, exit_status) => eprintln!("{mode:?} got {exit_status}"),
@@ -160,7 +157,6 @@ pub fn run_tests(config: Config) {
160157
"expected because of pattern here: {}:{definition_line}",
161158
path.display().to_string().bold()
162159
);
163-
dump_stderr = dump_stderr.map(|_| true);
164160
}
165161
Error::NoPatternsFound => {
166162
eprintln!("{}", "no error patterns found in failure test".red());
@@ -169,7 +165,7 @@ pub fn run_tests(config: Config) {
169165
eprintln!("{}", "error pattern found in success test".red()),
170166
Error::OutputDiffers { path, actual, expected } => {
171167
if path.extension().unwrap() == "stderr" {
172-
dump_stderr = None;
168+
dump_stderr = false;
173169
}
174170
eprintln!("actual output differed from expected {}", path.display());
175171
eprintln!("{}", pretty_assertions::StrComparison::new(expected, actual));
@@ -203,7 +199,8 @@ pub fn run_tests(config: Config) {
203199
}
204200
eprintln!();
205201
}
206-
if let Some(true) = dump_stderr {
202+
// Unless we already dumped the stderr via an OutputDiffers diff, let's dump it here.
203+
if dump_stderr {
207204
eprintln!("actual stderr:");
208205
eprintln!("{}", stderr);
209206
eprintln!();

0 commit comments

Comments
 (0)