@@ -14,27 +14,51 @@ use std::io::prelude::*;
14
14
use std:: io;
15
15
use std:: process:: { Command , Stdio } ;
16
16
17
- #[ unwind( aborts) ] // FIXME(#58794)
17
+ #[ unwind( aborts) ] // FIXME(#58794) should work even without the attribute
18
18
extern "C" fn panic_in_ffi ( ) {
19
19
panic ! ( "Test" ) ;
20
20
}
21
21
22
+ #[ unwind( aborts) ]
23
+ extern "Rust" fn panic_in_rust_abi ( ) {
24
+ panic ! ( "TestRust" ) ;
25
+ }
26
+
22
27
fn test ( ) {
23
28
let _ = panic:: catch_unwind ( || { panic_in_ffi ( ) ; } ) ;
24
29
// The process should have aborted by now.
25
30
io:: stdout ( ) . write ( b"This should never be printed.\n " ) ;
26
31
let _ = io:: stdout ( ) . flush ( ) ;
27
32
}
28
33
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
+
29
41
fn main ( ) {
30
42
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
+ }
33
50
}
34
51
52
+ // These end up calling the self-execution branches above.
35
53
let mut p = Command :: new ( & args[ 0 ] )
36
54
. stdout ( Stdio :: piped ( ) )
37
55
. stdin ( Stdio :: piped ( ) )
38
56
. arg ( "test" ) . spawn ( ) . unwrap ( ) ;
39
57
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( ) ) ;
40
64
}
0 commit comments