Skip to content

Commit 2fe4cad

Browse files
committed
Allow passing the --nocapture flag to compiletest
1 parent ef03fda commit 2fe4cad

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

src/tools/compiletest/src/common.rs

+2
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,8 @@ pub struct Config {
384384
pub only_modified: bool,
385385

386386
pub target_cfg: LazyCell<TargetCfg>,
387+
388+
pub nocapture: bool,
387389
}
388390

389391
impl Config {

src/tools/compiletest/src/main.rs

+11-4
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
151151
)
152152
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
153153
.optflag("", "only-modified", "only run tests that result been modified")
154+
.optflag("", "nocapture", "")
154155
.optflag("h", "help", "show this message")
155156
.reqopt("", "channel", "current Rust channel", "CHANNEL")
156157
.optopt("", "edition", "default Rust edition", "EDITION");
@@ -304,6 +305,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
304305
force_rerun: matches.opt_present("force-rerun"),
305306

306307
target_cfg: LazyCell::new(),
308+
309+
nocapture: matches.opt_present("nocapture"),
307310
}
308311
}
309312

@@ -496,6 +499,13 @@ fn configure_lldb(config: &Config) -> Option<Config> {
496499
}
497500

498501
pub fn test_opts(config: &Config) -> test::TestOpts {
502+
if env::var("RUST_TEST_NOCAPTURE").is_ok() {
503+
eprintln!(
504+
"WARNING: RUST_TEST_NOCAPTURE is no longer used. \
505+
Use the `--nocapture` flag instead."
506+
);
507+
}
508+
499509
test::TestOpts {
500510
exclude_should_panic: false,
501511
filters: config.filters.clone(),
@@ -505,10 +515,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
505515
logfile: config.logfile.clone(),
506516
run_tests: true,
507517
bench_benchmarks: true,
508-
nocapture: match env::var("RUST_TEST_NOCAPTURE") {
509-
Ok(val) => &val != "0",
510-
Err(_) => false,
511-
},
518+
nocapture: config.nocapture,
512519
color: config.color,
513520
shuffle: false,
514521
shuffle_seed: None,

0 commit comments

Comments
 (0)