about summary refs log tree commit diff
path: root/src/tools/compiletest
diff options
context:
space:
mode:
authorMichael Woerister <michaelwoerister@posteo.net>2016-08-30 16:49:54 -0400
committerMichael Woerister <michaelwoerister@posteo.net>2016-09-23 17:23:23 -0400
commit6a2666d5b01d92d5e33487ea8c4aba9e00359a80 (patch)
tree3df9fe5856f4c24350fca27f4a988aded9b96f10 /src/tools/compiletest
parentf2c53ea66bc1491ef125b35fa30c1cc890cde82c (diff)
downloadrust-6a2666d5b01d92d5e33487ea8c4aba9e00359a80.tar.gz
rust-6a2666d5b01d92d5e33487ea8c4aba9e00359a80.zip
ICH: Add ability to test the ICH of exported metadata items.
Diffstat (limited to 'src/tools/compiletest')
-rw-r--r--src/tools/compiletest/src/header.rs50
-rw-r--r--src/tools/compiletest/src/runtest.rs29
2 files changed, 45 insertions, 34 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index 899a366a4bb..503a8516769 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -182,42 +182,32 @@ 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.
+    pub must_compile_successfully: bool,
 }
 
 impl TestProps {
     pub fn new() -> Self {
-        let error_patterns = Vec::new();
-        let aux_builds = Vec::new();
-        let exec_env = Vec::new();
-        let run_flags = None;
-        let pp_exact = None;
-        let check_lines = Vec::new();
-        let build_aux_docs = false;
-        let force_host = false;
-        let check_stdout = false;
-        let no_prefer_dynamic = false;
-        let pretty_expanded = false;
-        let pretty_compare_only = false;
-        let forbid_output = Vec::new();
         TestProps {
-            error_patterns: error_patterns,
+            error_patterns: vec![],
             compile_flags: vec![],
-            run_flags: run_flags,
-            pp_exact: pp_exact,
-            aux_builds: aux_builds,
+            run_flags: None,
+            pp_exact: None,
+            aux_builds: vec![],
             revisions: vec![],
             rustc_env: vec![],
-            exec_env: exec_env,
-            check_lines: check_lines,
-            build_aux_docs: build_aux_docs,
-            force_host: force_host,
-            check_stdout: check_stdout,
-            no_prefer_dynamic: no_prefer_dynamic,
-            pretty_expanded: pretty_expanded,
+            exec_env: vec![],
+            check_lines: vec![],
+            build_aux_docs: false,
+            force_host: false,
+            check_stdout: false,
+            no_prefer_dynamic: false,
+            pretty_expanded: false,
             pretty_mode: format!("normal"),
-            pretty_compare_only: pretty_compare_only,
-            forbid_output: forbid_output,
+            pretty_compare_only: false,
+            forbid_output: vec![],
             incremental_dir: None,
+            must_compile_successfully: false,
         }
     }
 
@@ -313,6 +303,10 @@ impl TestProps {
             if let Some(of) = parse_forbid_output(ln) {
                 self.forbid_output.push(of);
             }
+
+            if !self.must_compile_successfully {
+                self.must_compile_successfully = parse_must_compile_successfully(ln);
+            }
         });
 
         for key in vec!["RUST_TEST_NOCAPTURE", "RUST_TEST_THREADS"] {
@@ -420,6 +414,10 @@ fn parse_pretty_compare_only(line: &str) -> bool {
     parse_name_directive(line, "pretty-compare-only")
 }
 
+fn parse_must_compile_successfully(line: &str) -> bool {
+    parse_name_directive(line, "must-compile-successfully")
+}
+
 fn parse_env(line: &str, name: &str) -> Option<(String, String)> {
     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 bfb85dd479d..9e490738402 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -129,13 +129,21 @@ impl<'test> TestCx<'test> {
     fn run_cfail_test(&self) {
         let proc_res = self.compile_test();
 
-        if proc_res.status.success() {
-            self.fatal_proc_rec(
-                &format!("{} test compiled successfully!", self.config.mode)[..],
-                &proc_res);
-        }
+        if self.props.must_compile_successfully {
+            if !proc_res.status.success() {
+                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);
+            }
 
-        self.check_correct_failure_status(&proc_res);
+            self.check_correct_failure_status(&proc_res);
+        }
 
         let output_to_check = self.get_output(&proc_res);
         let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@@ -147,6 +155,7 @@ impl<'test> TestCx<'test> {
         } else {
             self.check_error_patterns(&output_to_check, &proc_res);
         }
+
         self.check_no_compiler_crash(&proc_res);
         self.check_forbid_output(&output_to_check, &proc_res);
     }
@@ -943,8 +952,12 @@ actual:\n\
                             output_to_check: &str,
                             proc_res: &ProcRes) {
         if self.props.error_patterns.is_empty() {
-            self.fatal(&format!("no error pattern specified in {:?}",
-                                self.testpaths.file.display()));
+            if self.props.must_compile_successfully {
+                return
+            } else {
+                self.fatal(&format!("no error pattern specified in {:?}",
+                                    self.testpaths.file.display()));
+            }
         }
         let mut next_err_idx = 0;
         let mut next_err_pat = self.props.error_patterns[next_err_idx].trim();