Skip to content

Commit fb17900

Browse files
committed
Rollup merge of rust-lang#22371 - fhahn:issue-17829-compiletest-nocapture, r=Manishearth
This is a patch for rust-lang#17829. In `compiletest` there are multiple layers which capture the output. The first layer is `run_tests_console` which is used to execute all tests. Then there are some tests that contain unit tests, which by default also captures output. Therefore `compiletest` adds `RUST_TEST_NOCAPTURE` (and `RUST_TEST_TASKS` for completeness) to the run environment of the task. Finally, the task used to execute a test redirects stdout and stdin. At the moment, the `VERBOSE=1` prints all captured output of the task (but has to print stdout and stderr separately). So at the moment using `RUST_TEST_NOCAPTURE=1` only makes sense when also using `VERBOSE=1` which seems a little bit cumbersome. Should I update the patch to only print the output of the tasks that actually execute the test (`VERBOSE=1` includes other stuff, like the output of the task used to compile the test)? This will probably involve adding an extra flag to some functions in `src/compiletest/runtest.rs` to distinguish compilation runs from runs that execute the actual tests.
2 parents f71ca70 + ef1308c commit fb17900

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/compiletest/compiletest.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
268268
logfile: config.logfile.clone(),
269269
run_tests: true,
270270
run_benchmarks: true,
271-
nocapture: false,
271+
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
272272
color: test::AutoColor,
273273
}
274274
}

src/compiletest/header.rs

+12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
use std::env;
12+
1113
use common::Config;
1214
use common;
1315
use util;
@@ -125,6 +127,16 @@ pub fn load_props(testfile: &Path) -> TestProps {
125127
true
126128
});
127129

130+
for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
131+
match env::var(key) {
132+
Ok(val) =>
133+
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {
134+
exec_env.push((key.to_string(), val))
135+
},
136+
Err(..) => {}
137+
}
138+
}
139+
128140
TestProps {
129141
error_patterns: error_patterns,
130142
compile_flags: compile_flags,

0 commit comments

Comments
 (0)