@@ -29,53 +29,53 @@ fn main() {
29
29
30
30
let me = env:: current_exe ( ) . unwrap ( ) ;
31
31
32
- let output = Command :: new ( & me) . arg ( "test1" ) . before_exec ( || {
32
+ let output = unsafe { Command :: new ( & me) . arg ( "test1" ) . pre_exec ( || {
33
33
println ! ( "hello" ) ;
34
34
Ok ( ( ) )
35
- } ) . output ( ) . unwrap ( ) ;
35
+ } ) . output ( ) . unwrap ( ) } ;
36
36
assert ! ( output. status. success( ) ) ;
37
37
assert ! ( output. stderr. is_empty( ) ) ;
38
38
assert_eq ! ( output. stdout, b"hello\n hello2\n " ) ;
39
39
40
- let output = Command :: new ( & me) . arg ( "test2" ) . before_exec ( || {
40
+ let output = unsafe { Command :: new ( & me) . arg ( "test2" ) . pre_exec ( || {
41
41
env:: set_var ( "FOO" , "BAR" ) ;
42
42
Ok ( ( ) )
43
- } ) . output ( ) . unwrap ( ) ;
43
+ } ) . output ( ) . unwrap ( ) } ;
44
44
assert ! ( output. status. success( ) ) ;
45
45
assert ! ( output. stderr. is_empty( ) ) ;
46
46
assert ! ( output. stdout. is_empty( ) ) ;
47
47
48
- let output = Command :: new ( & me) . arg ( "test3" ) . before_exec ( || {
48
+ let output = unsafe { Command :: new ( & me) . arg ( "test3" ) . pre_exec ( || {
49
49
env:: set_current_dir ( "/" ) . unwrap ( ) ;
50
50
Ok ( ( ) )
51
- } ) . output ( ) . unwrap ( ) ;
51
+ } ) . output ( ) . unwrap ( ) } ;
52
52
assert ! ( output. status. success( ) ) ;
53
53
assert ! ( output. stderr. is_empty( ) ) ;
54
54
assert ! ( output. stdout. is_empty( ) ) ;
55
55
56
- let output = Command :: new ( & me) . arg ( "bad" ) . before_exec ( || {
56
+ let output = unsafe { Command :: new ( & me) . arg ( "bad" ) . pre_exec ( || {
57
57
Err ( Error :: from_raw_os_error ( 102 ) )
58
- } ) . output ( ) . unwrap_err ( ) ;
58
+ } ) . output ( ) . unwrap_err ( ) } ;
59
59
assert_eq ! ( output. raw_os_error( ) , Some ( 102 ) ) ;
60
60
61
61
let pid = unsafe { libc:: getpid ( ) } ;
62
62
assert ! ( pid >= 0 ) ;
63
- let output = Command :: new ( & me) . arg ( "empty" ) . before_exec ( move || {
64
- let child = unsafe { libc:: getpid ( ) } ;
63
+ let output = unsafe { Command :: new ( & me) . arg ( "empty" ) . pre_exec ( move || {
64
+ let child = libc:: getpid ( ) ;
65
65
assert ! ( child >= 0 ) ;
66
66
assert ! ( pid != child) ;
67
67
Ok ( ( ) )
68
- } ) . output ( ) . unwrap ( ) ;
68
+ } ) . output ( ) . unwrap ( ) } ;
69
69
assert ! ( output. status. success( ) ) ;
70
70
assert ! ( output. stderr. is_empty( ) ) ;
71
71
assert ! ( output. stdout. is_empty( ) ) ;
72
72
73
73
let mem = Arc :: new ( AtomicUsize :: new ( 0 ) ) ;
74
74
let mem2 = mem. clone ( ) ;
75
- let output = Command :: new ( & me) . arg ( "empty" ) . before_exec ( move || {
75
+ let output = unsafe { Command :: new ( & me) . arg ( "empty" ) . pre_exec ( move || {
76
76
assert_eq ! ( mem2. fetch_add( 1 , Ordering :: SeqCst ) , 0 ) ;
77
77
Ok ( ( ) )
78
- } ) . output ( ) . unwrap ( ) ;
78
+ } ) . output ( ) . unwrap ( ) } ;
79
79
assert ! ( output. status. success( ) ) ;
80
80
assert ! ( output. stderr. is_empty( ) ) ;
81
81
assert ! ( output. stdout. is_empty( ) ) ;
0 commit comments