Skip to content

Commit

Permalink
compiletest: don't use std::io::stdout(), as it bypasses set_print.
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyb committed Apr 1, 2020
1 parent 99009bf commit f181778
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,25 @@ pub fn make_diff(expected: &str, actual: &str, context_size: usize) -> Vec<Misma
}

fn print_diff(expected: &str, actual: &str, context_size: usize) {
write_diff(expected, actual, context_size, std::io::stdout());
}

fn write_diff(expected: &str, actual: &str, context_size: usize, mut dest: impl io::Write) {
let diff_results = make_diff(expected, actual, context_size);
for result in diff_results {
let mut line_number = result.line_number;
for line in result.lines {
match line {
DiffLine::Expected(e) => {
writeln!(dest, "-\t{}", e).unwrap();
println!("-\t{}", e);
line_number += 1;
}
DiffLine::Context(c) => {
writeln!(dest, "{}\t{}", line_number, c).unwrap();
println!("{}\t{}", line_number, c);
line_number += 1;
}
DiffLine::Resulting(r) => {
writeln!(dest, "+\t{}", r).unwrap();
println!("+\t{}", r);
}
}
}
writeln!(dest).unwrap();
println!();
}
}

Expand Down

0 comments on commit f181778

Please sign in to comment.