@@ -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 {
@@ -2011,18 +2008,34 @@ impl<'test> TestCx<'test> {
20112008 }
20122009
20132010 fn fatal_proc_rec ( & self , err : & str , proc_res : & ProcRes ) -> ! {
2014- self . error ( err) ;
2015- proc_res. fatal ( None , || ( ) ) ;
2011+ self . fatal_proc_rec_general ( err, None , proc_res, || ( ) ) ;
20162012 }
20172013
2018- fn fatal_proc_rec_with_ctx (
2014+ /// Underlying implementation of [`Self::fatal_proc_rec`], providing some
2015+ /// extra capabilities not needed by most callers.
2016+ fn fatal_proc_rec_general (
20192017 & self ,
20202018 err : & str ,
2019+ extra_note : Option < & str > ,
20212020 proc_res : & ProcRes ,
2022- on_failure : impl FnOnce ( Self ) ,
2021+ callback_before_unwind : impl FnOnce ( ) ,
20232022 ) -> ! {
20242023 self . error ( err) ;
2025- proc_res. fatal ( None , || on_failure ( * self ) ) ;
2024+
2025+ // Some callers want to print additional notes after the main error message.
2026+ if let Some ( note) = extra_note {
2027+ println ! ( "{note}" ) ;
2028+ }
2029+
2030+ // Print the details and output of the subprocess that caused this test to fail.
2031+ println ! ( "{}" , proc_res. format_info( ) ) ;
2032+
2033+ // Some callers want print more context or show a custom diff before the unwind occurs.
2034+ callback_before_unwind ( ) ;
2035+
2036+ // Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
2037+ // compiletest, which is unnecessary noise.
2038+ std:: panic:: resume_unwind ( Box :: new ( ( ) ) ) ;
20262039 }
20272040
20282041 // codegen tests (using FileCheck)
@@ -2081,7 +2094,7 @@ impl<'test> TestCx<'test> {
20812094 if cfg ! ( target_os = "freebsd" ) { "ISO-8859-1" } else { "UTF-8" }
20822095 }
20832096
2084- fn compare_to_default_rustdoc ( & mut self , out_dir : & Utf8Path ) {
2097+ fn compare_to_default_rustdoc ( & self , out_dir : & Utf8Path ) {
20852098 if !self . config . has_html_tidy {
20862099 return ;
20872100 }
@@ -2983,17 +2996,6 @@ impl ProcRes {
29832996 render( "stderr" , & self . stderr) ,
29842997 )
29852998 }
2986-
2987- pub fn fatal ( & self , err : Option < & str > , on_failure : impl FnOnce ( ) ) -> ! {
2988- if let Some ( e) = err {
2989- println ! ( "\n error: {}" , e) ;
2990- }
2991- println ! ( "{}" , self . format_info( ) ) ;
2992- on_failure ( ) ;
2993- // Use resume_unwind instead of panic!() to prevent a panic message + backtrace from
2994- // compiletest, which is unnecessary noise.
2995- std:: panic:: resume_unwind ( Box :: new ( ( ) ) ) ;
2996- }
29972999}
29983000
29993001#[ derive( Debug ) ]
0 commit comments