@@ -43,6 +43,8 @@ pub fn inject(
4343 span_diagnostic : & errors:: Handler ,
4444 features : & Features ,
4545 panic_strategy : PanicStrategy ,
46+ platform_panic_strategy : PanicStrategy ,
47+ enable_panic_abort_tests : bool ,
4648) {
4749 // Check for #![reexport_test_harness_main = "some_name"] which gives the
4850 // main test function the name `some_name` without hygiene. This needs to be
@@ -56,6 +58,20 @@ pub fn inject(
5658 let test_runner = get_test_runner ( span_diagnostic, & krate) ;
5759
5860 if should_test {
61+ let panic_strategy = match ( panic_strategy, enable_panic_abort_tests) {
62+ ( PanicStrategy :: Abort , true ) =>
63+ PanicStrategy :: Abort ,
64+ ( PanicStrategy :: Abort , false ) if panic_strategy == platform_panic_strategy => {
65+ // Silently allow compiling with panic=abort on these platforms,
66+ // but with old behavior (abort if a test fails).
67+ PanicStrategy :: Unwind
68+ }
69+ ( PanicStrategy :: Abort , false ) => {
70+ span_diagnostic. err ( "building tests with panic=abort is not yet supported" ) ;
71+ PanicStrategy :: Unwind
72+ }
73+ ( PanicStrategy :: Unwind , _) => PanicStrategy :: Unwind ,
74+ } ;
5975 generate_test_harness ( sess, resolver, reexport_test_harness_main,
6076 krate, features, panic_strategy, test_runner)
6177 }
0 commit comments