Skip to content

Commit e6e4a0a

Browse files
committed
Capture stdout and stderr of diff so they'll be printed at the end
1 parent 619880e commit e6e4a0a

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/tools/compiletest/src/runtest.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2382,7 +2382,7 @@ impl<'test> TestCx<'test> {
23822382
AllowUnused::Yes,
23832383
);
23842384
rustc.arg("-L").arg(&new_rustdoc.aux_output_dir_name());
2385-
new_rustdoc.build_all_auxiliary(&mut dbg!(rustc));
2385+
new_rustdoc.build_all_auxiliary(&mut rustc);
23862386

23872387
let proc_res = new_rustdoc.document(&compare_dir);
23882388
if !proc_res.status.success() {
@@ -2414,19 +2414,25 @@ impl<'test> TestCx<'test> {
24142414
let mut diff = Command::new("diff");
24152415
diff.args(&["-u", "-r"]).args(&[out_dir, &compare_dir]);
24162416

2417-
if has_delta {
2417+
let output = if has_delta {
24182418
let diff_pid = diff.stdout(Stdio::piped()).spawn().expect("failed to run `diff`");
2419-
let status = Command::new("delta")
2419+
let output = Command::new("delta")
24202420
.arg("--paging=never")
24212421
.stdin(diff_pid.stdout.unwrap())
2422-
.status()
2422+
// Capture output and print it explicitly so it will in turn be
2423+
// captured by libtest.
2424+
.output()
24232425
.unwrap();
2424-
assert!(status.success());
2426+
assert!(output.status.success());
2427+
output
24252428
} else {
24262429
eprintln!("warning: `delta` not installed, falling back to `diff --color`");
2427-
diff.arg("--color").spawn().expect("failed to run `diff`").wait().unwrap();
2428-
assert!(status.success() || status.code() == Some(1));
2429-
}
2430+
let output = diff.arg("--color").output().unwrap();
2431+
assert!(output.status.success() || output.status.code() == Some(1));
2432+
output
2433+
};
2434+
println!("{}", String::from_utf8_lossy(&output.stdout));
2435+
eprintln!("{}", String::from_utf8_lossy(&output.stderr));
24302436
}
24312437

24322438
fn get_lines<P: AsRef<Path>>(

0 commit comments

Comments
 (0)