Skip to content

Commit

Permalink
Don't capture child process output at all when --no-capture is used
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 18, 2021
1 parent 893e07e commit 6461cde
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,16 +460,22 @@ fn run_test(
cmd.current_dir(run_directory);
}

match cmd.output() {
let result = if options.nocapture {
cmd.status().map(|status| process::Output {
status,
stdout: Vec::new(),
stderr: Vec::new(),
})
} else {
cmd.output()
};
match result {
Err(e) => return Err(TestFailure::ExecutionError(e)),
Ok(out) => {
if should_panic && out.status.success() {
return Err(TestFailure::UnexpectedRunPass);
} else if !should_panic && !out.status.success() {
return Err(TestFailure::ExecutionFailure(out));
} else if options.nocapture {
io::stdout().write_all(&out.stdout).expect("failed to write stdout");
io::stderr().write_all(&out.stderr).expect("failed to write stderr");
}
}
}
Expand Down

0 comments on commit 6461cde

Please sign in to comment.