@@ -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).
246246fn 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 {
248248self . fatal ( "cannot use should-ice in a test that is not cfail" ) ;
249249}
250250match self . config . mode {
@@ -263,6 +263,7 @@ impl<'test> TestCx<'test> {
263263JsDocTest => self . run_js_doc_test ( ) ,
264264CoverageMap => self . run_coverage_map_test ( ) ,
265265CoverageRun => self . run_coverage_run_test ( ) ,
266+ Crashes => self . run_crash_test ( ) ,
266267}
267268}
268269
@@ -295,6 +296,7 @@ impl<'test> TestCx<'test> {
295296match self . config . mode {
296297JsDocTest => true ,
297298Ui => pm. is_some ( ) || self . props . fail_mode > Some ( FailMode :: Build ) ,
299+ Crashes => false ,
298300Incremental => {
299301let revision =
300302self . revision . expect ( "incremental tests require a list of revisions" ) ;
@@ -359,6 +361,17 @@ impl<'test> TestCx<'test> {
359361self . 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+
362375fn run_rfail_test ( & self ) {
363376let pm = self . pass_mode ( ) ;
364377let should_run = self . run_if_enabled ( ) ;
@@ -2517,7 +2530,7 @@ impl<'test> TestCx<'test> {
25172530 rustc. arg ( "-Cdebug-assertions=no" ) ;
25182531}
25192532RunPassValgrind | Pretty | DebugInfo | Rustdoc | RustdocJson | RunMake
2520- | CodegenUnits | JsDocTest => {
2533+ | CodegenUnits | JsDocTest | Crashes => {
25212534// do not use JSON output
25222535}
25232536}
0 commit comments