Skip to content

Commit 7d4d450

Browse files
authored
Rollup merge of #70662 - eddyb:compiletest-stdout-fix, r=Mark-Simulacrum
compiletest: don't use `std::io::stdout()`, as it bypasses `set_print`. This PR undoes a change made during #69916, which became unnecessary during review but was left in by accident, and which isn't correct due to `libtest` using `std::io::set_print`, which overwrites the `println!` behavior but *not* `writeln!(std::io::stdout(), ...)`. The effect of using `writeln!(std::io::stdout(), ...)` was that the diff output would show *while* running the tests, instead of at the end, when failing tests are listed. r? @Mark-Simulacrum cc @oli-obk
2 parents 37b2e3f + f181778 commit 7d4d450

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/tools/compiletest/src/runtest.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -180,29 +180,25 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma
180180
}
181181

182182
fn print_diff(expected: &str, actual: &str, context_size: usize) {
183-
write_diff(expected, actual, context_size, std::io::stdout());
184-
}
185-
186-
fn write_diff(expected: &str, actual: &str, context_size: usize, mut dest: impl io::Write) {
187183
let diff_results = make_diff(expected, actual, context_size);
188184
for result in diff_results {
189185
let mut line_number = result.line_number;
190186
for line in result.lines {
191187
match line {
192188
DiffLine::Expected(e) => {
193-
writeln!(dest, "-\t{}", e).unwrap();
189+
println!("-\t{}", e);
194190
line_number += 1;
195191
}
196192
DiffLine::Context(c) => {
197-
writeln!(dest, "{}\t{}", line_number, c).unwrap();
193+
println!("{}\t{}", line_number, c);
198194
line_number += 1;
199195
}
200196
DiffLine::Resulting(r) => {
201-
writeln!(dest, "+\t{}", r).unwrap();
197+
println!("+\t{}", r);
202198
}
203199
}
204200
}
205-
writeln!(dest).unwrap();
201+
println!();
206202
}
207203
}
208204

0 commit comments

Comments
 (0)