about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/test/debuginfo/should-fail.rs1
-rw-r--r--src/test/ui/meta/revision-bad.rs1
-rw-r--r--src/tools/compiletest/src/common.rs9
-rw-r--r--src/tools/compiletest/src/header.rs4
-rw-r--r--src/tools/compiletest/src/runtest.rs6
5 files changed, 16 insertions, 5 deletions
diff --git a/src/test/debuginfo/should-fail.rs b/src/test/debuginfo/should-fail.rs
index 1e0d22cbce4..eef6d99d2a9 100644
--- a/src/test/debuginfo/should-fail.rs
+++ b/src/test/debuginfo/should-fail.rs
@@ -2,6 +2,7 @@
 
 // == Test [gdb|lldb]-[command|check] are parsed correctly ===
 // should-fail
+// needs-run-enabled
 // compile-flags:-g
 
 // === GDB TESTS ===================================================================================
diff --git a/src/test/ui/meta/revision-bad.rs b/src/test/ui/meta/revision-bad.rs
index 01f1518c1c6..37ddbe99a9f 100644
--- a/src/test/ui/meta/revision-bad.rs
+++ b/src/test/ui/meta/revision-bad.rs
@@ -4,6 +4,7 @@
 // run-fail
 // revisions: foo bar
 // should-fail
+// needs-run-enabled
 //[foo] error-pattern:bar
 //[bar] error-pattern:foo
 
diff --git a/src/tools/compiletest/src/common.rs b/src/tools/compiletest/src/common.rs
index 9a2166675d8..2a14d8a3999 100644
--- a/src/tools/compiletest/src/common.rs
+++ b/src/tools/compiletest/src/common.rs
@@ -351,6 +351,15 @@ pub struct Config {
     pub npm: Option<String>,
 }
 
+impl Config {
+    pub fn run_enabled(&self) -> bool {
+        self.run.unwrap_or_else(|| {
+            // Auto-detect whether to run based on the platform.
+            !self.target.ends_with("-fuchsia")
+        })
+    }
+}
+
 #[derive(Debug, Clone)]
 pub struct TestPaths {
     pub file: PathBuf,         // e.g., compile-test/foo/bar/baz.rs
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index f31a24738df..56527420c0d 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -85,6 +85,10 @@ impl EarlyProps {
                     props.ignore = true;
                 }
 
+                if !config.run_enabled() && config.parse_name_directive(ln, "needs-run-enabled") {
+                    props.ignore = true;
+                }
+
                 if !rustc_has_sanitizer_support
                     && config.parse_name_directive(ln, "needs-sanitizer-support")
                 {
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index c87a0c8c8d9..c606aa1dfbf 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -369,11 +369,7 @@ impl<'test> TestCx<'test> {
     }
 
     fn run_if_enabled(&self) -> WillExecute {
-        let enabled = self.config.run.unwrap_or_else(|| {
-            // Auto-detect whether to run based on the platform.
-            !self.config.target.ends_with("-fuchsia")
-        });
-        if enabled { WillExecute::Yes } else { WillExecute::Disabled }
+        if self.config.run_enabled() { WillExecute::Yes } else { WillExecute::Disabled }
     }
 
     fn should_run_successfully(&self, pm: Option<PassMode>) -> bool {