avoid overlapping stderr

This commit is contained in:
Pietro Albini 2023-03-02 16:20:18 +01:00
parent 50b3583695
commit ad9a444241
No known key found for this signature in database
GPG key ID: CD76B35F7734769E

View file

@ -7,7 +7,7 @@
//! to reimplement all the rendering logic in this module because of that.
use crate::builder::Builder;
use std::io::{BufRead, BufReader, Write};
use std::io::{BufRead, BufReader, Cursor, Write};
use std::process::{ChildStdout, Command, Stdio};
use std::time::Duration;
use yansi_term::Color;
@ -43,6 +43,7 @@ pub(crate) fn try_run_tests(builder: &Builder<'_>, cmd: &mut Command) -> bool {
fn run_tests(builder: &Builder<'_>, cmd: &mut Command) -> bool {
cmd.stdout(Stdio::piped());
cmd.stderr(Stdio::piped());
builder.verbose(&format!("running: {cmd:?}"));
@ -52,15 +53,20 @@ fn run_tests(builder: &Builder<'_>, cmd: &mut Command) -> bool {
// run this on another thread since the builder is not Sync.
Renderer::new(process.stdout.take().unwrap(), builder).render_all();
let result = process.wait().unwrap();
if !result.success() && builder.is_verbose() {
let result = process.wait_with_output().unwrap();
if !result.status.success() && builder.is_verbose() {
println!(
"\n\ncommand did not execute successfully: {cmd:?}\n\
expected success, got: {result}"
expected success, got: {}",
result.status
);
}
result.success()
// Show the stderr emitted by the test runner at the end. As of 2023-03-02 this is only the
// message at the end of a failed compiletest run.
std::io::copy(&mut Cursor::new(&result.stderr), &mut std::io::stderr().lock()).unwrap();
result.status.success()
}
struct Renderer<'a> {