about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTommy Ip <hkmp7tommy@gmail.com>2017-12-10 17:11:48 +0000
committerTommy Ip <hkmp7tommy@gmail.com>2017-12-10 21:14:57 +0000
commit5990b8b57caaaf89024791bc053224cd1266aaf4 (patch)
tree05ae13e75ab52e9f8eaddcb88c7cea0501fa660d
parent2537a499c2f1983011ad04ba2e59e5ff2e2989b6 (diff)
downloadrust-5990b8b57caaaf89024791bc053224cd1266aaf4.tar.gz
rust-5990b8b57caaaf89024791bc053224cd1266aaf4.zip
Enforce successful ui tests to have must-compile-successfully flag.
-rw-r--r--src/tools/compiletest/src/header.rs2
-rw-r--r--src/tools/compiletest/src/runtest.rs16
2 files changed, 11 insertions, 7 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index e7851c36327..8d8eb4d5cb8 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -218,7 +218,7 @@ pub struct TestProps {
     // testing harness and used when generating compilation
     // arguments. (In particular, it propagates to the aux-builds.)
     pub incremental_dir: Option<PathBuf>,
-    // Specifies that a cfail test must actually compile without errors.
+    // Specifies that a test must actually compile without errors.
     pub must_compile_successfully: bool,
     // rustdoc will test the output of the `--test` option
     pub check_test_line_numbers_match: bool,
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index a18f4ec1aad..74da774c6d5 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -147,23 +147,26 @@ impl<'test> TestCx<'test> {
         assert!(self.revision.is_none(), "init_all invoked for a revision");
     }
 
-    fn run_cfail_test(&self) {
-        let proc_res = self.compile_test();
-
+    fn check_if_test_should_compile(&self, proc_res: &ProcRes) {
         if self.props.must_compile_successfully {
             if !proc_res.status.success() {
-                self.fatal_proc_rec("test compilation failed although it shouldn't!", &proc_res);
+                self.fatal_proc_rec("test compilation failed although it shouldn't!", proc_res);
             }
         } else {
             if proc_res.status.success() {
                 self.fatal_proc_rec(
                     &format!("{} test compiled successfully!", self.config.mode)[..],
-                    &proc_res,
+                    proc_res,
                 );
             }
 
-            self.check_correct_failure_status(&proc_res);
+            self.check_correct_failure_status(proc_res);
         }
+    }
+
+    fn run_cfail_test(&self) {
+        let proc_res = self.compile_test();
+        self.check_if_test_should_compile(&proc_res);
 
         let output_to_check = self.get_output(&proc_res);
         let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@@ -2388,6 +2391,7 @@ impl<'test> TestCx<'test> {
             .any(|s| s.contains("--error-format"));
 
         let proc_res = self.compile_test();
+        self.check_if_test_should_compile(&proc_res);
 
         let expected_stderr_path = self.expected_output_path(UI_STDERR);
         let expected_stderr = self.load_expected_output(&expected_stderr_path);