@@ -14,27 +14,51 @@ use std::io::prelude::*;
1414use std:: io;
1515use std:: process:: { Command , Stdio } ;
1616
17- #[ unwind( aborts) ] // FIXME(#58794)
17+ #[ unwind( aborts) ] // FIXME(#58794) should work even without the attribute
1818extern "C" fn panic_in_ffi ( ) {
1919 panic ! ( "Test" ) ;
2020}
2121
22+ #[ unwind( aborts) ]
23+ extern "Rust" fn panic_in_rust_abi ( ) {
24+ panic ! ( "TestRust" ) ;
25+ }
26+
2227fn test ( ) {
2328 let _ = panic:: catch_unwind ( || { panic_in_ffi ( ) ; } ) ;
2429 // The process should have aborted by now.
2530 io:: stdout ( ) . write ( b"This should never be printed.\n " ) ;
2631 let _ = io:: stdout ( ) . flush ( ) ;
2732}
2833
34+ fn testrust ( ) {
35+ let _ = panic:: catch_unwind ( || { panic_in_rust_abi ( ) ; } ) ;
36+ // The process should have aborted by now.
37+ io:: stdout ( ) . write ( b"This should never be printed.\n " ) ;
38+ let _ = io:: stdout ( ) . flush ( ) ;
39+ }
40+
2941fn main ( ) {
3042 let args: Vec < String > = env:: args ( ) . collect ( ) ;
31- if args. len ( ) > 1 && args[ 1 ] == "test" {
32- return test ( ) ;
43+ if args. len ( ) > 1 {
44+ // This is inside the self-executed command.
45+ match & * args[ 1 ] {
46+ "test" => return test ( ) ,
47+ "testrust" => return testrust ( ) ,
48+ _ => panic ! ( "bad test" ) ,
49+ }
3350 }
3451
52+ // These end up calling the self-execution branches above.
3553 let mut p = Command :: new ( & args[ 0 ] )
3654 . stdout ( Stdio :: piped ( ) )
3755 . stdin ( Stdio :: piped ( ) )
3856 . arg ( "test" ) . spawn ( ) . unwrap ( ) ;
3957 assert ! ( !p. wait( ) . unwrap( ) . success( ) ) ;
58+
59+ let mut p = Command :: new ( & args[ 0 ] )
60+ . stdout ( Stdio :: piped ( ) )
61+ . stdin ( Stdio :: piped ( ) )
62+ . arg ( "testrust" ) . spawn ( ) . unwrap ( ) ;
63+ assert ! ( !p. wait( ) . unwrap( ) . success( ) ) ;
4064}
0 commit comments