@@ -4,7 +4,7 @@ use crate::common::{
44 expected_output_path, UI_EXTENSIONS , UI_FIXED , UI_STDERR , UI_STDOUT , UI_SVG , UI_WINDOWS_SVG ,
55} ;
66use crate :: common:: { incremental_dir, output_base_dir, output_base_name, output_testname_unique} ;
7- use crate :: common:: { Assembly , Incremental , JsDocTest , MirOpt , RunMake , RustdocJson , Ui } ;
7+ use crate :: common:: { Assembly , Crashes , Incremental , JsDocTest , MirOpt , RunMake , RustdocJson , Ui } ;
88use crate :: common:: { Codegen , CodegenUnits , DebugInfo , Debugger , Rustdoc } ;
99use crate :: common:: { CompareMode , FailMode , PassMode } ;
1010use crate :: common:: { Config , TestPaths } ;
@@ -244,7 +244,7 @@ impl<'test> TestCx<'test> {
244244 /// Code executed for each revision in turn (or, if there are no
245245 /// revisions, exactly once, with revision == None).
246246 fn run_revision ( & self ) {
247- if self . props . should_ice && self . config . mode != Incremental {
247+ if self . props . should_ice && self . config . mode != Incremental && self . config . mode != Crashes {
248248 self . fatal ( "cannot use should-ice in a test that is not cfail" ) ;
249249 }
250250 match self . config . mode {
@@ -263,6 +263,7 @@ impl<'test> TestCx<'test> {
263263 JsDocTest => self . run_js_doc_test ( ) ,
264264 CoverageMap => self . run_coverage_map_test ( ) ,
265265 CoverageRun => self . run_coverage_run_test ( ) ,
266+ Crashes => self . run_crash_test ( ) ,
266267 }
267268 }
268269
@@ -295,6 +296,7 @@ impl<'test> TestCx<'test> {
295296 match self . config . mode {
296297 JsDocTest => true ,
297298 Ui => pm. is_some ( ) || self . props . fail_mode > Some ( FailMode :: Build ) ,
299+ Crashes => false ,
298300 Incremental => {
299301 let revision =
300302 self . revision . expect ( "incremental tests require a list of revisions" ) ;
@@ -359,6 +361,17 @@ impl<'test> TestCx<'test> {
359361 self . check_forbid_output ( & output_to_check, & proc_res) ;
360362 }
361363
364+ fn run_crash_test ( & self ) {
365+ let pm = self . pass_mode ( ) ;
366+ let proc_res = self . compile_test ( WillExecute :: No , self . should_emit_metadata ( pm) ) ;
367+
368+ // if a test does not crash, consider it an error
369+ match proc_res. status . code ( ) {
370+ Some ( 101 ) => ( ) ,
371+ _ => self . fatal ( "expected ICE" ) ,
372+ }
373+ }
374+
362375 fn run_rfail_test ( & self ) {
363376 let pm = self . pass_mode ( ) ;
364377 let should_run = self . run_if_enabled ( ) ;
@@ -2499,7 +2512,7 @@ impl<'test> TestCx<'test> {
24992512 rustc. arg ( "-Cdebug-assertions=no" ) ;
25002513 }
25012514 RunPassValgrind | Pretty | DebugInfo | Rustdoc | RustdocJson | RunMake
2502- | CodegenUnits | JsDocTest => {
2515+ | CodegenUnits | JsDocTest | Crashes => {
25032516 // do not use JSON output
25042517 }
25052518 }
0 commit comments