diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2020-02-06 14:43:53 -0800 |
|---|---|---|
| committer | Tyler Mandry <tmandry@gmail.com> | 2020-02-06 14:43:53 -0800 |
| commit | 861b328f7d62aebd1cfe381eb81bc7e80faf758e (patch) | |
| tree | 2e3c94e7501198b3212286372d43e5a1bc6cbbc5 /src/libtest | |
| parent | 442ae7f04026c215a03b155eaaf9cde8bb5cf02a (diff) | |
| download | rust-861b328f7d62aebd1cfe381eb81bc7e80faf758e.tar.gz rust-861b328f7d62aebd1cfe381eb81bc7e80faf758e.zip | |
Respect --nocapture in panic=abort test mode
Diffstat (limited to 'src/libtest')
| -rw-r--r-- | src/libtest/lib.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/libtest/lib.rs b/src/libtest/lib.rs index e99473177e8..de001cacbe1 100644 --- a/src/libtest/lib.rs +++ b/src/libtest/lib.rs @@ -63,8 +63,7 @@ use std::{ env, io, io::prelude::Write, panic::{self, catch_unwind, AssertUnwindSafe, PanicInfo}, - process, - process::{Command, Termination}, + process::{self, Command, Termination}, sync::mpsc::{channel, Sender}, sync::{Arc, Mutex}, thread, @@ -457,9 +456,13 @@ pub fn run_test( monitor_ch, opts.time, ), - RunStrategy::SpawnPrimary => { - spawn_test_subprocess(desc, opts.time.is_some(), monitor_ch, opts.time) - } + RunStrategy::SpawnPrimary => spawn_test_subprocess( + desc, + opts.nocapture, + opts.time.is_some(), + monitor_ch, + opts.time, + ), }; // If the platform is single-threaded we're just going to run @@ -558,6 +561,7 @@ fn run_test_in_process( fn spawn_test_subprocess( desc: TestDesc, + nocapture: bool, report_time: bool, monitor_ch: Sender<CompletedTest>, time_opts: Option<time::TestTimeOptions>, @@ -566,11 +570,15 @@ fn spawn_test_subprocess( let args = env::args().collect::<Vec<_>>(); let current_exe = &args[0]; + let mut command = Command::new(current_exe); + command.env(SECONDARY_TEST_INVOKER_VAR, desc.name.as_slice()); + if nocapture { + command.stdout(process::Stdio::inherit()); + command.stderr(process::Stdio::inherit()); + } + let start = report_time.then(Instant::now); - let output = match Command::new(current_exe) - .env(SECONDARY_TEST_INVOKER_VAR, desc.name.as_slice()) - .output() - { + let output = match command.output() { Ok(out) => out, Err(e) => { let err = format!("Failed to spawn {} as child for test: {:?}", args[0], e); |
