Skip to content

Commit df453d9

Browse files
Rollup merge of #109445 - Teapot4195:issue-109407-fix, r=ozkanonur
Allow passing the --nocapture flag to compiletest closes #109407
2 parents b1e8be7 + 2fe4cad commit df453d9

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
@@ -152,6 +152,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
152152
)
153153
.optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
154154
.optflag("", "only-modified", "only run tests that result been modified")
155+
.optflag("", "nocapture", "")
155156
.optflag("h", "help", "show this message")
156157
.reqopt("", "channel", "current Rust channel", "CHANNEL")
157158
.optopt("", "edition", "default Rust edition", "EDITION");
@@ -310,6 +311,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
310311
force_rerun: matches.opt_present("force-rerun"),
311312

312313
target_cfg: LazyCell::new(),
314+
315+
nocapture: matches.opt_present("nocapture"),
313316
}
314317
}
315318

@@ -502,6 +505,13 @@ fn configure_lldb(config: &Config) -> Option<Config> {
502505
}
503506

504507
pub fn test_opts(config: &Config) -> test::TestOpts {
508+
if env::var("RUST_TEST_NOCAPTURE").is_ok() {
509+
eprintln!(
510+
"WARNING: RUST_TEST_NOCAPTURE is no longer used. \
511+
Use the `--nocapture` flag instead."
512+
);
513+
}
514+
505515
test::TestOpts {
506516
exclude_should_panic: false,
507517
filters: config.filters.clone(),
@@ -511,10 +521,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
511521
logfile: config.logfile.clone(),
512522
run_tests: true,
513523
bench_benchmarks: true,
514-
nocapture: match env::var("RUST_TEST_NOCAPTURE") {
515-
Ok(val) => &val != "0",
516-
Err(_) => false,
517-
},
524+
nocapture: config.nocapture,
518525
color: config.color,
519526
shuffle: false,
520527
shuffle_seed: None,

0 commit comments

Comments
 (0)