Skip to content

Commit 6299c33

Browse files
committed
add header to compiletest to check for ice
1 parent 5930551 commit 6299c33

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,8 @@ pub struct TestProps {
376376
// If true, `rustfix` will only apply `MachineApplicable` suggestions.
377377
pub rustfix_only_machine_applicable: bool,
378378
pub assembly_output: Option<String>,
379+
// If true, the test is expected to ICE
380+
pub should_ice: bool,
379381
}
380382

381383
impl TestProps {
@@ -414,6 +416,7 @@ impl TestProps {
414416
run_rustfix: false,
415417
rustfix_only_machine_applicable: false,
416418
assembly_output: None,
419+
should_ice: false,
417420
}
418421
}
419422

@@ -464,6 +467,10 @@ impl TestProps {
464467
self.pp_exact = config.parse_pp_exact(ln, testfile);
465468
}
466469

470+
if !self.should_ice {
471+
self.should_ice = config.parse_should_ice(ln);
472+
}
473+
467474
if !self.build_aux_docs {
468475
self.build_aux_docs = config.parse_build_aux_docs(ln);
469476
}
@@ -688,6 +695,9 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut dyn FnMut(&str)) {
688695
}
689696

690697
impl Config {
698+
fn parse_should_ice(&self, line: &str) -> bool {
699+
self.parse_name_directive(line, "should-ice")
700+
}
691701
fn parse_error_pattern(&self, line: &str) -> Option<String> {
692702
self.parse_name_value_directive(line, "error-pattern")
693703
}

src/tools/compiletest/src/runtest.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ impl<'test> TestCx<'test> {
383383
fn run_cfail_test(&self) {
384384
let proc_res = self.compile_test();
385385
self.check_if_test_should_compile(&proc_res);
386-
self.check_no_compiler_crash(&proc_res);
386+
self.check_no_compiler_crash(&proc_res, self.props.should_ice);
387387

388388
let output_to_check = self.get_output(&proc_res);
389389
let expected_errors = errors::load_errors(&self.testpaths.file, self.revision);
@@ -395,6 +395,12 @@ impl<'test> TestCx<'test> {
395395
} else {
396396
self.check_error_patterns(&output_to_check, &proc_res);
397397
}
398+
if self.props.should_ice {
399+
match proc_res.status.code() {
400+
Some(101) => (),
401+
_ => self.fatal("expected ICE"),
402+
}
403+
}
398404

399405
self.check_forbid_output(&output_to_check, &proc_res);
400406
}
@@ -1402,9 +1408,9 @@ impl<'test> TestCx<'test> {
14021408
}
14031409
}
14041410

1405-
fn check_no_compiler_crash(&self, proc_res: &ProcRes) {
1411+
fn check_no_compiler_crash(&self, proc_res: &ProcRes, should_ice: bool) {
14061412
match proc_res.status.code() {
1407-
Some(101) => self.fatal_proc_rec("compiler encountered internal error", proc_res),
1413+
Some(101) if !should_ice => self.fatal_proc_rec("compiler encountered internal error", proc_res),
14081414
None => self.fatal_proc_rec("compiler terminated by signal", proc_res),
14091415
_ => (),
14101416
}
@@ -2518,7 +2524,7 @@ impl<'test> TestCx<'test> {
25182524
self.fatal_proc_rec("compilation failed!", &proc_res);
25192525
}
25202526

2521-
self.check_no_compiler_crash(&proc_res);
2527+
self.check_no_compiler_crash(&proc_res, self.props.should_ice);
25222528

25232529
const PREFIX: &'static str = "MONO_ITEM ";
25242530
const CGU_MARKER: &'static str = "@@";

0 commit comments

Comments
 (0)