about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorkennytm <kennytm@gmail.com>2017-05-13 17:54:50 +0800
committerkennytm <kennytm@gmail.com>2017-06-02 23:28:22 +0800
commit38ef85696dce84d5e6aff171cbf91d396678cbe0 (patch)
treed7a2b1e86e632a6947fbc9c801b6846f7c718af8 /src/tools/compiletest
parentd7798c3d179c7c18736fc0465e7ba6618c575a34 (diff)
downloadrust-38ef85696dce84d5e6aff171cbf91d396678cbe0.tar.gz
rust-38ef85696dce84d5e6aff171cbf91d396678cbe0.zip
Introduce 'run-pass' header to 'ui' tests in compiletest. Fix issue #36516.
The 'run-pass' header cause a 'ui' test to execute the result. It is used
to test the lint output, at the same time ensure those lints won't cause
the source code to become compile-fail.

12 run-pass/run-pass-fulldeps tests gained the header and are moved to
ui/ui-fulldeps. After this move, no run-pass/run-pass-fulldeps tests should
rely on the compiler's JSON message. This allows us to stop passing
`--error-format json` in run-pass tests, thus fixing #36516.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/header.rs12
-rw-r--r--src/tools/compiletest/src/runtest.rs16
2 files changed, 24 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 0f653dfbcf0..e0999ae7793 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -233,6 +233,9 @@ pub struct TestProps {
     pub must_compile_successfully: bool,
     // rustdoc will test the output of the `--test` option
     pub check_test_line_numbers_match: bool,
+    // The test must be compiled and run successfully. Only used in UI tests for
+    // now.
+    pub run_pass: bool,
 }
 
 impl TestProps {
@@ -258,6 +261,7 @@ impl TestProps {
             incremental_dir: None,
             must_compile_successfully: false,
             check_test_line_numbers_match: false,
+            run_pass: false,
         }
     }
 
@@ -368,6 +372,10 @@ impl TestProps {
             if !self.check_test_line_numbers_match {
                 self.check_test_line_numbers_match = config.parse_check_test_line_numbers_match(ln);
             }
+
+            if !self.run_pass {
+                self.run_pass = config.parse_run_pass(ln);
+            }
         });
 
         for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
@@ -485,6 +493,10 @@ impl Config {
         self.parse_name_directive(line, "check-test-line-numbers-match")
     }
 
+    fn parse_run_pass(&self, line: &str) -> bool {
+        self.parse_name_directive(line, "run-pass")
+    }
+
     fn parse_env(&self, line: &str, name: &str) -> Option<(String, String)> {
         self.parse_name_value_directive(line, name).map(|nv| {
             // nv is either FOO or FOO=BAR
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index 1bec6f6af83..01419c42570 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -214,10 +214,10 @@ impl<'test> TestCx<'test> {
             self.fatal_proc_rec("compilation failed!", &proc_res);
         }
 
+        // FIXME(#41968): Move this check to tidy?
         let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
-        if !expected_errors.is_empty() {
-            self.check_expected_errors(expected_errors, &proc_res);
-        }
+        assert!(expected_errors.is_empty(),
+                "run-pass tests with expected warnings should be moved to ui/");
 
         let proc_res = self.exec_compiled_test();
 
@@ -1394,7 +1394,6 @@ actual:\n\
         match self.config.mode {
             CompileFail |
             ParseFail |
-            RunPass |
             Incremental => {
                 // If we are extracting and matching errors in the new
                 // fashion, then you want JSON mode. Old-skool error
@@ -1422,6 +1421,7 @@ actual:\n\
 
                 args.push(dir_opt);
             }
+            RunPass |
             RunFail |
             RunPassValgrind |
             Pretty |
@@ -2254,6 +2254,14 @@ actual:\n\
             self.fatal_proc_rec(&format!("{} errors occurred comparing output.", errors),
                                 &proc_res);
         }
+
+        if self.props.run_pass {
+            let proc_res = self.exec_compiled_test();
+
+            if !proc_res.status.success() {
+                self.fatal_proc_rec("test run failed!", &proc_res);
+            }
+        }
     }
 
     fn run_mir_opt_test(&self) {