Skip to content

Commit

Permalink
Rollup merge of rust-lang#22371 - fhahn:issue-17829-compiletest-nocap…
Browse files Browse the repository at this point in the history
…ture, 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.
  • Loading branch information
Manishearth committed Feb 23, 2015
2 parents 46a5451 + ef1308c commit 1acd7c9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
logfile: config.logfile.clone(),
run_tests: true,
run_benchmarks: true,
nocapture: false,
nocapture: env::var("RUST_TEST_NOCAPTURE").is_ok(),
color: test::AutoColor,
}
}
Expand Down
12 changes: 12 additions & 0 deletions src/compiletest/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use std::env;

use common::Config;
use common;
use util;
Expand Down Expand Up @@ -125,6 +127,16 @@ pub fn load_props(testfile: &Path) -> TestProps {
true
});

for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_TASKS"] {
match env::var(key) {
Ok(val) =>
if exec_env.iter().find(|&&(ref x, _)| *x == key.to_string()).is_none() {
exec_env.push((key.to_string(), val))
},
Err(..) => {}
}
}

TestProps {
error_patterns: error_patterns,
compile_flags: compile_flags,
Expand Down

0 comments on commit 1acd7c9

Please sign in to comment.