@@ -354,13 +354,10 @@ impl<'test> TestCx<'test> {
354354 }
355355 } else {
356356 if proc_res. status . success ( ) {
357- {
358- self . error ( & format ! ( "{} test did not emit an error" , self . config. mode) ) ;
359- if self . config . mode == crate :: common:: TestMode :: Ui {
360- println ! ( "note: by default, ui tests are expected not to compile" ) ;
361- }
362- proc_res. fatal ( None , || ( ) ) ;
363- } ;
357+ let err = & format ! ( "{} test did not emit an error" , self . config. mode) ;
358+ let extra_note = ( self . config . mode == crate :: common:: TestMode :: Ui )
359+ . then_some ( "note: by default, ui tests are expected not to compile" ) ;
360+ self . fatal_proc_rec_general ( err, extra_note, proc_res, || ( ) ) ;
364361 }
365362
366363 if !self . props . dont_check_failure_status {
@@ -2010,18 +2007,34 @@ impl<'test> TestCx<'test> {
20102007 }
20112008
20122009 fn fatal_proc_rec ( & self , err : & str , proc_res : & ProcRes ) -> ! {
2013- self . error ( err) ;
2014- proc_res. fatal ( None , || ( ) ) ;
2010+ self . fatal_proc_rec_general ( err, None , proc_res, || ( ) ) ;
20152011 }
20162012
2017- fn fatal_proc_rec_with_ctx (
2013+ /// Underlying implementation of [`Self::fatal_proc_rec`], providing some
2014+ /// extra capabilities not needed by most callers.
2015+ fn fatal_proc_rec_general (
20182016 & self ,
20192017 err : & str ,
2018+ extra_note : Option < & str > ,
20202019 proc_res : & ProcRes ,
2021- on_failure : impl FnOnce ( Self ) ,
2020+ callback_before_unwind : impl FnOnce ( ) ,
20222021 ) -> ! {
20232022 self . error ( err) ;
2024- proc_res. fatal ( None , || on_failure ( * self ) ) ;
2023+
2024+ // Some callers want to print additional notes after the main error message.
2025+ if let Some ( note) = extra_note {
2026+ println ! ( "{note}" ) ;
2027+ }
2028+
2029+ // Print the details and output of the subprocess that caused this test to fail.
2030+ println ! ( "{}" , proc_res. format_info( ) ) ;
2031+
2032+ // Some callers want print more context or show a custom diff before the unwind occurs.
2033+ callback_before_unwind ( ) ;
2034+
2035+ // Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
2036+ // compiletest, which is unnecessary noise.
2037+ std:: panic:: resume_unwind ( Box :: new ( ( ) ) ) ;
20252038 }
20262039
20272040 // codegen tests (using FileCheck)
@@ -2080,7 +2093,7 @@ impl<'test> TestCx<'test> {
20802093 if cfg ! ( target_os = "freebsd" ) { "ISO-8859-1" } else { "UTF-8" }
20812094 }
20822095
2083- fn compare_to_default_rustdoc ( & mut self , out_dir : & Utf8Path ) {
2096+ fn compare_to_default_rustdoc ( & self , out_dir : & Utf8Path ) {
20842097 if !self . config . has_html_tidy {
20852098 return ;
20862099 }
@@ -2982,17 +2995,6 @@ impl ProcRes {
29822995 render( "stderr" , & self . stderr) ,
29832996 )
29842997 }
2985-
2986- pub fn fatal ( & self , err : Option < & str > , on_failure : impl FnOnce ( ) ) -> ! {
2987- if let Some ( e) = err {
2988- println ! ( "\n error: {}" , e) ;
2989- }
2990- println ! ( "{}" , self . format_info( ) ) ;
2991- on_failure ( ) ;
2992- // Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
2993- // compiletest, which is unnecessary noise.
2994- std:: panic:: resume_unwind ( Box :: new ( ( ) ) ) ;
2995- }
29962998}
29972999
29983000#[ derive( Debug ) ]
0 commit comments