@@ -109,30 +109,20 @@ fn util_name_single() {
109109#[ test]
110110#[ cfg( unix) ]
111111fn util_invalid_name_help ( ) {
112- use std:: process:: { Command , Stdio } ;
112+ use std:: process:: Command ;
113113
114114 let scenario = TestScenario :: new ( "invalid_name" ) ;
115115 if !scenario. bin_path . exists ( ) {
116116 println ! ( "Skipping test: Binary not found at {:?}" , scenario. bin_path) ;
117117 return ;
118118 }
119119 symlink_file ( & scenario. bin_path , scenario. fixtures . plus ( "invalid_name" ) ) . unwrap ( ) ;
120- let child = Command :: new ( scenario. fixtures . plus ( "invalid_name" ) )
120+ let code = Command :: new ( scenario. fixtures . plus ( "invalid_name" ) )
121121 . arg ( "--help" )
122- . stdin ( Stdio :: piped ( ) )
123- . stdout ( Stdio :: piped ( ) )
124- . stderr ( Stdio :: piped ( ) )
125- . spawn ( )
126- . unwrap ( ) ;
127- let output = child. wait_with_output ( ) . unwrap ( ) ;
128- assert_eq ! ( output. status. code( ) , Some ( 0 ) ) ;
129- assert_eq ! ( output. stderr, b"" ) ;
130- let output_str = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
131- assert ! ( output_str. contains( "(multi-call binary)" ) , "{output_str:?}" ) ;
132- assert ! (
133- output_str. contains( "Usage: invalid_name [function " ) ,
134- "{output_str:?}"
135- ) ;
122+ . status ( )
123+ . unwrap ( )
124+ . code ( ) ;
125+ assert_eq ! ( code, Some ( 1 ) ) ; // for GNU compat
136126}
137127
138128#[ test]
@@ -177,7 +167,7 @@ fn util_non_utf8_name_help() {
177167#[ test]
178168#[ cfg( unix) ]
179169fn util_invalid_name_invalid_command ( ) {
180- use std:: process:: { Command , Stdio } ;
170+ use std:: process:: Command ;
181171
182172 let scenario = TestScenario :: new ( "invalid_name" ) ;
183173 symlink_file ( & scenario. bin_path , scenario. fixtures . plus ( "invalid_name" ) ) . unwrap ( ) ;
@@ -186,20 +176,11 @@ fn util_invalid_name_invalid_command() {
186176 return ;
187177 }
188178
189- let child = Command :: new ( scenario. fixtures . plus ( "invalid_name" ) )
190- . arg ( "definitely_invalid" )
191- . stdin ( Stdio :: piped ( ) )
192- . stdout ( Stdio :: piped ( ) )
193- . stderr ( Stdio :: piped ( ) )
194- . spawn ( )
195- . unwrap ( ) ;
196- let output = child. wait_with_output ( ) . unwrap ( ) ;
197- assert_eq ! ( output. status. code( ) , Some ( 1 ) ) ;
198- assert_eq ! ( output. stdout, b"" ) ;
199- assert_eq ! (
200- output. stderr,
201- b"definitely_invalid: function/utility not found\n "
202- ) ;
179+ let code = Command :: new ( scenario. fixtures . plus ( "invalid_name" ) )
180+ . status ( )
181+ . unwrap ( )
182+ . code ( ) ;
183+ assert_eq ! ( code, Some ( 1 ) ) ; //for GNU compat
203184}
204185
205186#[ test]
0 commit comments