@@ -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 {
@@ -2011,18 +2008,34 @@ impl<'test> TestCx<'test> {
2011
2008
}
2012
2009
2013
2010
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, || ( ) ) ;
2016
2012
}
2017
2013
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 (
2019
2017
& self ,
2020
2018
err : & str ,
2019
+ extra_note : Option < & str > ,
2021
2020
proc_res : & ProcRes ,
2022
- on_failure : impl FnOnce ( Self ) ,
2021
+ callback_before_unwind : impl FnOnce ( ) ,
2023
2022
) -> ! {
2024
2023
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 ( ( ) ) ) ;
2026
2039
}
2027
2040
2028
2041
// codegen tests (using FileCheck)
@@ -2081,7 +2094,7 @@ impl<'test> TestCx<'test> {
2081
2094
if cfg ! ( target_os = "freebsd" ) { "ISO-8859-1" } else { "UTF-8" }
2082
2095
}
2083
2096
2084
- fn compare_to_default_rustdoc ( & mut self , out_dir : & Utf8Path ) {
2097
+ fn compare_to_default_rustdoc ( & self , out_dir : & Utf8Path ) {
2085
2098
if !self . config . has_html_tidy {
2086
2099
return ;
2087
2100
}
@@ -2983,17 +2996,6 @@ impl ProcRes {
2983
2996
render( "stderr" , & self . stderr) ,
2984
2997
)
2985
2998
}
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
- }
2997
2999
}
2998
3000
2999
3001
#[ derive( Debug ) ]
0 commit comments