@@ -354,13 +354,10 @@ impl<'test> TestCx<'test> {
354
354
}
355
355
} else {
356
356
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, || ( ) ) ;
364
361
}
365
362
366
363
if !self . props . dont_check_failure_status {
@@ -2010,18 +2007,34 @@ impl<'test> TestCx<'test> {
2010
2007
}
2011
2008
2012
2009
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, || ( ) ) ;
2015
2011
}
2016
2012
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 (
2018
2016
& self ,
2019
2017
err : & str ,
2018
+ extra_note : Option < & str > ,
2020
2019
proc_res : & ProcRes ,
2021
- on_failure : impl FnOnce ( Self ) ,
2020
+ callback_before_unwind : impl FnOnce ( ) ,
2022
2021
) -> ! {
2023
2022
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 ( ( ) ) ) ;
2025
2038
}
2026
2039
2027
2040
// codegen tests (using FileCheck)
@@ -2080,7 +2093,7 @@ impl<'test> TestCx<'test> {
2080
2093
if cfg ! ( target_os = "freebsd" ) { "ISO-8859-1" } else { "UTF-8" }
2081
2094
}
2082
2095
2083
- fn compare_to_default_rustdoc ( & mut self , out_dir : & Utf8Path ) {
2096
+ fn compare_to_default_rustdoc ( & self , out_dir : & Utf8Path ) {
2084
2097
if !self . config . has_html_tidy {
2085
2098
return ;
2086
2099
}
@@ -2982,17 +2995,6 @@ impl ProcRes {
2982
2995
render( "stderr" , & self . stderr) ,
2983
2996
)
2984
2997
}
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
- }
2996
2998
}
2997
2999
2998
3000
#[ derive( Debug ) ]
0 commit comments