about summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Boyer <qbsecond@gmail.com>2019-11-03 16:42:09 +0100
committerQuentin Boyer <qbsecond@gmail.com>2019-11-03 16:42:09 +0100
commit6299c3302216174de41a24ca44033f978cd64666 (patch)
treef8e77adb716d8f49497f5065df8928dcaf791db0
parent5930551f6a471164d61d0b67cd412b32461924e3 (diff)
downloadrust-6299c3302216174de41a24ca44033f978cd64666.tar.gz
rust-6299c3302216174de41a24ca44033f978cd64666.zip
add header to compiletest to check for ice
-rw-r--r--src/tools/compiletest/src/header.rs10
-rw-r--r--src/tools/compiletest/src/runtest.rs14
2 files changed, 20 insertions, 4 deletions
diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs
index df56448dd22..f63b5997a4a 100644
--- a/src/tools/compiletest/src/header.rs
+++ b/src/tools/compiletest/src/header.rs
@@ -376,6 +376,8 @@ pub struct TestProps {
     // If true, `rustfix` will only apply `MachineApplicable` suggestions.
     pub rustfix_only_machine_applicable: bool,
     pub assembly_output: Option<String>,
+    // If true, the test is expected to ICE
+    pub should_ice: bool,
 }
 
 impl TestProps {
@@ -414,6 +416,7 @@ impl TestProps {
             run_rustfix: false,
             rustfix_only_machine_applicable: false,
             assembly_output: None,
+            should_ice: false,
         }
     }
 
@@ -464,6 +467,10 @@ impl TestProps {
                 self.pp_exact = config.parse_pp_exact(ln, testfile);
             }
 
+            if !self.should_ice {
+                self.should_ice = config.parse_should_ice(ln);
+            }
+
             if !self.build_aux_docs {
                 self.build_aux_docs = config.parse_build_aux_docs(ln);
             }
@@ -688,6 +695,9 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
 }
 
 impl Config {
+    fn parse_should_ice(&self, line: &str) -> bool {
+        self.parse_name_directive(line, "should-ice")
+    }
     fn parse_error_pattern(&self, line: &str) -> Option<String> {
         self.parse_name_value_directive(line, "error-pattern")
     }
diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs
index ea31f37c7a5..c239e045cc1 100644
--- a/src/tools/compiletest/src/runtest.rs
+++ b/src/tools/compiletest/src/runtest.rs
@@ -383,7 +383,7 @@ impl<'test> TestCx<'test> {
     fn run_cfail_test(&self) {
         let proc_res = self.compile_test();
         self.check_if_test_should_compile(&proc_res);
-        self.check_no_compiler_crash(&proc_res);
+        self.check_no_compiler_crash(&proc_res, self.props.should_ice);
 
         let output_to_check = self.get_output(&proc_res);
         let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@@ -395,6 +395,12 @@ impl<'test> TestCx<'test> {
         } else {
             self.check_error_patterns(&output_to_check, &proc_res);
         }
+        if self.props.should_ice {
+            match proc_res.status.code() {
+                Some(101) => (),
+                _ => self.fatal("expected ICE"),
+            }
+        }
 
         self.check_forbid_output(&output_to_check, &proc_res);
     }
@@ -1402,9 +1408,9 @@ impl<'test> TestCx<'test> {
         }
     }
 
-    fn check_no_compiler_crash(&self, proc_res: &ProcRes) {
+    fn check_no_compiler_crash(&self, proc_res: &ProcRes, should_ice: bool) {
         match proc_res.status.code() {
-            Some(101) => self.fatal_proc_rec("compiler encountered internal error", proc_res),
+            Some(101) if !should_ice => self.fatal_proc_rec("compiler encountered internal error", proc_res),
             None => self.fatal_proc_rec("compiler terminated by signal", proc_res),
             _ => (),
         }
@@ -2518,7 +2524,7 @@ impl<'test> TestCx<'test> {
             self.fatal_proc_rec("compilation failed!", &proc_res);
         }
 
-        self.check_no_compiler_crash(&proc_res);
+        self.check_no_compiler_crash(&proc_res, self.props.should_ice);
 
         const PREFIX: &'static str = "MONO_ITEM ";
         const CGU_MARKER: &'static str = "@@";