about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlex Huang <huangalex409@gmail.com>2023-03-26 09:45:53 -0400
committerAlex Huang <huangalex409@gmail.com>2023-03-26 09:45:53 -0400
commit2fe4cad77f03e9eb323382e531d136f0e32b3645 (patch)
tree86dee0c04008f5a3534f4f322f3abebaf4d0220e
parentef03fda339923e659d3d3ca3321de887316d2807 (diff)
downloadrust-2fe4cad77f03e9eb323382e531d136f0e32b3645.tar.gz
rust-2fe4cad77f03e9eb323382e531d136f0e32b3645.zip
Allow passing the --nocapture flag to compiletest
-rw-r--r--src/tools/compiletest/src/common.rs2
-rw-r--r--src/tools/compiletest/src/main.rs15
2 files changed, 13 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 7fe2e6257d9..ff9c40afeb8 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -384,6 +384,8 @@ pub struct Config {
     pub only_modified: bool,
 
     pub target_cfg: LazyCell<TargetCfg>,
+
+    pub nocapture: bool,
 }
 
 impl Config {
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs
index 1760c29ec66..b9d53b7b07d 100644
--- a/src/tools/compiletest/src/main.rs
+++ b/src/tools/compiletest/src/main.rs
@@ -151,6 +151,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
         )
         .optflag("", "force-rerun", "rerun tests even if the inputs are unchanged")
         .optflag("", "only-modified", "only run tests that result been modified")
+        .optflag("", "nocapture", "")
         .optflag("h", "help", "show this message")
         .reqopt("", "channel", "current Rust channel", "CHANNEL")
         .optopt("", "edition", "default Rust edition", "EDITION");
@@ -304,6 +305,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
         force_rerun: matches.opt_present("force-rerun"),
 
         target_cfg: LazyCell::new(),
+
+        nocapture: matches.opt_present("nocapture"),
     }
 }
 
@@ -496,6 +499,13 @@ fn configure_lldb(config: &Config) -> Option<Config> {
 }
 
 pub fn test_opts(config: &Config) -> test::TestOpts {
+    if env::var("RUST_TEST_NOCAPTURE").is_ok() {
+        eprintln!(
+            "WARNING: RUST_TEST_NOCAPTURE is no longer used. \
+                   Use the `--nocapture` flag instead."
+        );
+    }
+
     test::TestOpts {
         exclude_should_panic: false,
         filters: config.filters.clone(),
@@ -505,10 +515,7 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
         logfile: config.logfile.clone(),
         run_tests: true,
         bench_benchmarks: true,
-        nocapture: match env::var("RUST_TEST_NOCAPTURE") {
-            Ok(val) => &val != "0",
-            Err(_) => false,
-        },
+        nocapture: config.nocapture,
         color: config.color,
         shuffle: false,
         shuffle_seed: None,