Skip to content

Commit c0a94c1

Browse files
Don't capture child process output at all when --no-capture is used
1 parent 769602b commit c0a94c1

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/librustdoc/doctest.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,22 @@ fn run_test(
460460
cmd.current_dir(run_directory);
461461
}
462462

463-
match cmd.output() {
463+
let result = if options.nocapture {
464+
cmd.status().map(|status| process::Output {
465+
status,
466+
stdout: Vec::new(),
467+
stderr: Vec::new(),
468+
})
469+
} else {
470+
cmd.output()
471+
};
472+
match result {
464473
Err(e) => return Err(TestFailure::ExecutionError(e)),
465474
Ok(out) => {
466475
if should_panic && out.status.success() {
467476
return Err(TestFailure::UnexpectedRunPass);
468477
} else if !should_panic && !out.status.success() {
469478
return Err(TestFailure::ExecutionFailure(out));
470-
} else if options.nocapture {
471-
io::stdout().write_all(&out.stdout).expect("failed to write stdout");
472-
io::stderr().write_all(&out.stderr).expect("failed to write stderr");
473479
}
474480
}
475481
}

0 commit comments

Comments
 (0)