@@ -112,97 +112,94 @@ fn test_if_windows_batch_files_can_be_executed() {
112112#[ test]
113113fn test_debug_1 ( ) {
114114 let ts = TestScenario :: new ( util_name ! ( ) ) ;
115- let result = ts
116- . ucmd ( )
115+
116+ ts . ucmd ( )
117117 . arg ( "-v" )
118118 . arg ( & ts. bin_path )
119119 . args ( & [ "echo" , "hello" ] )
120- . succeeds ( ) ;
121- result . stderr_matches (
122- & Regex :: new ( concat ! (
123- r"executing: [^\n]+(\/|\\)coreutils(\.exe)?\n" ,
124- r" arg\[0\]= '[^\n]+(\/|\\)coreutils(\.exe)?'\n" ,
125- r" arg\[1\]= 'echo'\n" ,
126- r" arg\[2\]= 'hello'"
127- ) )
128- . unwrap ( ) ,
129- ) ;
120+ . succeeds ( )
121+ . stderr_matches (
122+ & Regex :: new ( concat ! (
123+ r"executing: [^\n]+(\/|\\)coreutils(\.exe)?\n" ,
124+ r" arg\[0\]= '[^\n]+(\/|\\)coreutils(\.exe)?'\n" ,
125+ r" arg\[1\]= 'echo'\n" ,
126+ r" arg\[2\]= 'hello'"
127+ ) )
128+ . unwrap ( ) ,
129+ ) ;
130130}
131131
132132#[ cfg( feature = "echo" ) ]
133133#[ test]
134134fn test_debug_2 ( ) {
135135 let ts = TestScenario :: new ( util_name ! ( ) ) ;
136- let result = ts
137- . ucmd ( )
136+ ts. ucmd ( )
138137 . arg ( "-vv" )
139138 . arg ( & ts. bin_path )
140139 . args ( & [ "echo" , "hello2" ] )
141- . succeeds ( ) ;
142- result . stderr_matches (
143- & Regex :: new ( concat ! (
144- r"input args:\n" ,
145- r"arg\[0\]: 'env'\n" ,
146- r"arg\[1\]: '-vv'\n" ,
147- r"arg\[2\]: '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
148- r"arg\[3\]: 'echo'\n" ,
149- r"arg\[4\]: 'hello2'\n" ,
150- r"executing: [^\n]+(\/|\\)coreutils(.exe)?\n" ,
151- r" arg\[0\]= '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
152- r" arg\[1\]= 'echo'\n" ,
153- r" arg\[2\]= 'hello2'"
154- ) )
155- . unwrap ( ) ,
156- ) ;
140+ . succeeds ( )
141+ . stderr_matches (
142+ & Regex :: new ( concat ! (
143+ r"input args:\n" ,
144+ r"arg\[0\]: 'env'\n" ,
145+ r"arg\[1\]: '-vv'\n" ,
146+ r"arg\[2\]: '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
147+ r"arg\[3\]: 'echo'\n" ,
148+ r"arg\[4\]: 'hello2'\n" ,
149+ r"executing: [^\n]+(\/|\\)coreutils(.exe)?\n" ,
150+ r" arg\[0\]= '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
151+ r" arg\[1\]= 'echo'\n" ,
152+ r" arg\[2\]= 'hello2'"
153+ ) )
154+ . unwrap ( ) ,
155+ ) ;
157156}
158157
159158#[ cfg( feature = "echo" ) ]
160159#[ test]
161160fn test_debug1_part_of_string_arg ( ) {
162161 let ts = TestScenario :: new ( util_name ! ( ) ) ;
163162
164- let result = ts
165- . ucmd ( )
163+ ts. ucmd ( )
166164 . arg ( "-vS FOO=BAR" )
167165 . arg ( & ts. bin_path )
168166 . args ( & [ "echo" , "hello1" ] )
169- . succeeds ( ) ;
170- result . stderr_matches (
171- & Regex :: new ( concat ! (
172- r"executing: [^\n]+(\/|\\)coreutils(\.exe)?\n" ,
173- r" arg\[0\]= '[^\n]+(\/|\\)coreutils(\.exe)?'\n" ,
174- r" arg\[1\]= 'echo'\n" ,
175- r" arg\[2\]= 'hello1'"
176- ) )
177- . unwrap ( ) ,
178- ) ;
167+ . succeeds ( )
168+ . stderr_matches (
169+ & Regex :: new ( concat ! (
170+ r"executing: [^\n]+(\/|\\)coreutils(\.exe)?\n" ,
171+ r" arg\[0\]= '[^\n]+(\/|\\)coreutils(\.exe)?'\n" ,
172+ r" arg\[1\]= 'echo'\n" ,
173+ r" arg\[2\]= 'hello1'"
174+ ) )
175+ . unwrap ( ) ,
176+ ) ;
179177}
180178
181179#[ cfg( feature = "echo" ) ]
182180#[ test]
183181fn test_debug2_part_of_string_arg ( ) {
184182 let ts = TestScenario :: new ( util_name ! ( ) ) ;
185- let result = ts
186- . ucmd ( )
183+ ts. ucmd ( )
187184 . arg ( "-vvS FOO=BAR" )
188185 . arg ( & ts. bin_path )
189186 . args ( & [ "echo" , "hello2" ] )
190- . succeeds ( ) ;
191- result . stderr_matches (
192- & Regex :: new ( concat ! (
193- r"input args:\n" ,
194- r"arg\[0\]: 'env'\n" ,
195- r"arg\[1\]: '-vvS FOO=BAR'\n" ,
196- r"arg\[2\]: '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
197- r"arg\[3\]: 'echo'\n" ,
198- r"arg\[4\]: 'hello2'\n" ,
199- r"executing: [^\n]+(\/|\\)coreutils(.exe)?\n" ,
200- r" arg\[0\]= '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
201- r" arg\[1\]= 'echo'\n" ,
202- r" arg\[2\]= 'hello2'"
203- ) )
204- . unwrap ( ) ,
205- ) ;
187+ . succeeds ( )
188+ . stderr_matches (
189+ & Regex :: new ( concat ! (
190+ r"input args:\n" ,
191+ r"arg\[0\]: 'env'\n" ,
192+ r"arg\[1\]: '-vvS FOO=BAR'\n" ,
193+ r"arg\[2\]: '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
194+ r"arg\[3\]: 'echo'\n" ,
195+ r"arg\[4\]: 'hello2'\n" ,
196+ r"executing: [^\n]+(\/|\\)coreutils(.exe)?\n" ,
197+ r" arg\[0\]= '[^\n]+(\/|\\)coreutils(.exe)?'\n" ,
198+ r" arg\[1\]= 'echo'\n" ,
199+ r" arg\[2\]= 'hello2'"
200+ ) )
201+ . unwrap ( ) ,
202+ ) ;
206203}
207204
208205#[ test]
@@ -288,10 +285,8 @@ fn test_multiple_name_value_pairs() {
288285
289286#[ test]
290287fn test_ignore_environment ( ) {
291- let scene = TestScenario :: new ( util_name ! ( ) ) ;
292-
293- scene. ucmd ( ) . arg ( "-i" ) . succeeds ( ) . no_stdout ( ) ;
294- scene. ucmd ( ) . arg ( "-" ) . succeeds ( ) . no_stdout ( ) ;
288+ new_ucmd ! ( ) . arg ( "-i" ) . succeeds ( ) . no_stdout ( ) ;
289+ new_ucmd ! ( ) . arg ( "-" ) . succeeds ( ) . no_stdout ( ) ;
295290}
296291
297292#[ test]
@@ -323,8 +318,7 @@ fn test_null_delimiter() {
323318
324319#[ test]
325320fn test_unset_variable ( ) {
326- let out = TestScenario :: new ( util_name ! ( ) )
327- . ucmd ( )
321+ let out = new_ucmd ! ( )
328322 . env ( "HOME" , "FOO" )
329323 . arg ( "-u" )
330324 . arg ( "HOME" )
@@ -346,16 +340,15 @@ fn test_fail_null_with_program() {
346340#[ cfg( not( windows) ) ]
347341#[ test]
348342fn test_change_directory ( ) {
349- let scene = TestScenario :: new ( util_name ! ( ) ) ;
350343 let temporary_directory = tempdir ( ) . unwrap ( ) ;
351344 let temporary_path = std:: fs:: canonicalize ( temporary_directory. path ( ) ) . unwrap ( ) ;
345+
352346 assert_ne ! ( env:: current_dir( ) . unwrap( ) , temporary_path) ;
353347
354348 // command to print out current working directory
355349 let pwd = "pwd" ;
356350
357- let out = scene
358- . ucmd ( )
351+ let out = new_ucmd ! ( )
359352 . arg ( "--chdir" )
360353 . arg ( & temporary_path)
361354 . arg ( pwd)
@@ -367,7 +360,6 @@ fn test_change_directory() {
367360#[ cfg( windows) ]
368361#[ test]
369362fn test_change_directory ( ) {
370- let scene = TestScenario :: new ( util_name ! ( ) ) ;
371363 let temporary_directory = tempdir ( ) . unwrap ( ) ;
372364
373365 let temporary_path = temporary_directory. path ( ) ;
@@ -386,8 +378,7 @@ fn test_change_directory() {
386378 // command to print out current working directory
387379 let pwd = [ & * cmd_path, "/C" , "cd" ] ;
388380
389- let out = scene
390- . ucmd ( )
381+ let out = new_ucmd ! ( )
391382 . arg ( "--chdir" )
392383 . arg ( temporary_path)
393384 . args ( & pwd)
@@ -398,12 +389,10 @@ fn test_change_directory() {
398389
399390#[ test]
400391fn test_fail_change_directory ( ) {
401- let scene = TestScenario :: new ( util_name ! ( ) ) ;
402392 let some_non_existing_path = "some_nonexistent_path" ;
403393 assert ! ( !Path :: new( some_non_existing_path) . is_dir( ) ) ;
404394
405- let out = scene
406- . ucmd ( )
395+ let out = new_ucmd ! ( )
407396 . arg ( "--chdir" )
408397 . arg ( some_non_existing_path)
409398 . arg ( "pwd" )
@@ -415,95 +404,68 @@ fn test_fail_change_directory() {
415404#[ cfg( not( target_os = "windows" ) ) ] // windows has no executable "echo", its only supported as part of a batch-file
416405#[ test]
417406fn test_split_string_into_args_one_argument_no_quotes ( ) {
418- let scene = TestScenario :: new ( util_name ! ( ) ) ;
419-
420- let out = scene
421- . ucmd ( )
407+ new_ucmd ! ( )
422408 . arg ( "-S echo hello world" )
423409 . succeeds ( )
424- . stdout_move_str ( ) ;
425- assert_eq ! ( out, "hello world\n " ) ;
410+ . stdout_is ( "hello world\n " ) ;
426411}
427412
428413#[ cfg( not( target_os = "windows" ) ) ] // windows has no executable "echo", its only supported as part of a batch-file
429414#[ test]
430415fn test_split_string_into_args_one_argument ( ) {
431- let scene = TestScenario :: new ( util_name ! ( ) ) ;
432-
433- let out = scene
434- . ucmd ( )
416+ new_ucmd ! ( )
435417 . arg ( "-S echo \" hello world\" " )
436418 . succeeds ( )
437- . stdout_move_str ( ) ;
438- assert_eq ! ( out, "hello world\n " ) ;
419+ . stdout_is ( "hello world\n " ) ;
439420}
440421
441422#[ cfg( not( target_os = "windows" ) ) ] // windows has no executable "echo", its only supported as part of a batch-file
442423#[ test]
443424fn test_split_string_into_args_s_escaping_challenge ( ) {
444- let scene = TestScenario :: new ( util_name ! ( ) ) ;
445-
446- let out = scene
447- . ucmd ( )
425+ new_ucmd ! ( )
448426 . args ( & [ r#"-S echo "hello \"great\" world""# ] )
449427 . succeeds ( )
450- . stdout_move_str ( ) ;
451- assert_eq ! ( out, "hello \" great\" world\n " ) ;
428+ . stdout_is ( "hello \" great\" world\n " ) ;
452429}
453430
454431#[ test]
455432fn test_split_string_into_args_s_escaped_c_not_allowed ( ) {
456- let scene = TestScenario :: new ( util_name ! ( ) ) ;
457-
458- let out = scene. ucmd ( ) . args ( & [ r#"-S"\c""# ] ) . fails ( ) . stderr_move_str ( ) ;
459- assert_eq ! (
460- out,
461- "env: '\\ c' must not appear in double-quoted -S string\n "
462- ) ;
433+ new_ucmd ! ( )
434+ . args ( & [ r#"-S"\c""# ] )
435+ . fails ( )
436+ . stderr_is ( "env: '\\ c' must not appear in double-quoted -S string\n " ) ;
463437}
464438
465439#[ cfg( not( target_os = "windows" ) ) ] // no printf available
466440#[ test]
467441fn test_split_string_into_args_s_whitespace_handling ( ) {
468- let scene = TestScenario :: new ( util_name ! ( ) ) ;
469-
470- let out = scene
471- . ucmd ( )
442+ new_ucmd ! ( )
472443 . args ( & [ "-Sprintf x%sx\\ n A \t B \x0B \x0C \r \n " ] )
473444 . succeeds ( )
474- . stdout_move_str ( ) ;
475- assert_eq ! ( out, "xAx\n xBx\n " ) ;
445+ . stdout_is ( "xAx\n xBx\n " ) ;
476446}
477447
478448#[ cfg( not( target_os = "windows" ) ) ] // no printf available
479449#[ test]
480450fn test_split_string_into_args_long_option_whitespace_handling ( ) {
481- let scene = TestScenario :: new ( util_name ! ( ) ) ;
482-
483- let out = scene
484- . ucmd ( )
451+ new_ucmd ! ( )
485452 . args ( & [ "--split-string printf x%sx\\ n A \t B \x0B \x0C \r \n " ] )
486453 . succeeds ( )
487- . stdout_move_str ( ) ;
488- assert_eq ! ( out, "xAx\n xBx\n " ) ;
454+ . stdout_is ( "xAx\n xBx\n " ) ;
489455}
490456
491457#[ cfg( not( target_os = "windows" ) ) ] // no printf available
492458#[ test]
493459fn test_split_string_into_args_debug_output_whitespace_handling ( ) {
494- let scene = TestScenario :: new ( util_name ! ( ) ) ;
495-
496- let out = scene
497- . ucmd ( )
460+ new_ucmd ! ( )
498461 . args ( & [ "-vvS printf x%sx\\ n A \t B \x0B \x0C \r \n " ] )
499- . succeeds ( ) ;
500- assert_eq ! ( out. stdout_str( ) , "xAx\n xBx\n " ) ;
501- assert_eq ! (
502- out. stderr_str( ) ,
503- "input args:\n arg[0]: 'env'\n arg[1]: $\
462+ . succeeds ( )
463+ . stdout_is ( "xAx\n xBx\n " )
464+ . stderr_is (
465+ "input args:\n arg[0]: 'env'\n arg[1]: $\
504466 '-vvS printf x%sx\\ \\ n A \\ t B \\ x0B\\ x0C\\ r\\ n'\n executing: printf\
505- \n arg[0]= 'printf'\n arg[1]= $'x%sx\\ n'\n arg[2]= 'A'\n arg[3]= 'B'\n "
506- ) ;
467+ \n arg[0]= 'printf'\n arg[1]= $'x%sx\\ n'\n arg[2]= 'A'\n arg[3]= 'B'\n ",
468+ ) ;
507469}
508470
509471// FixMe: This test fails on MACOS:
@@ -513,8 +475,6 @@ fn test_split_string_into_args_debug_output_whitespace_handling() {
513475#[ cfg( not( target_os = "macos" ) ) ]
514476#[ test]
515477fn test_gnu_e20 ( ) {
516- let scene = TestScenario :: new ( util_name ! ( ) ) ;
517-
518478 let env_bin = String :: from ( crate :: common:: util:: TESTS_BINARY ) + " " + util_name ! ( ) ;
519479
520480 let ( input, output) = (
@@ -525,7 +485,7 @@ fn test_gnu_e20() {
525485 "A=B C=D\n " ,
526486 ) ;
527487
528- let out = scene . ucmd ( ) . args ( & input) . succeeds ( ) ;
488+ let out = new_ucmd ! ( ) . args ( & input) . succeeds ( ) ;
529489 assert_eq ! ( out. stdout_str( ) , output) ;
530490}
531491
@@ -627,9 +587,7 @@ fn test_env_parsing_errors() {
627587
628588#[ test]
629589fn test_env_with_empty_executable_single_quotes ( ) {
630- let ts = TestScenario :: new ( util_name ! ( ) ) ;
631-
632- ts. ucmd ( )
590+ new_ucmd ! ( )
633591 . args ( & [ "-S''" ] ) // empty single quotes, considered as program name
634592 . fails_with_code ( 127 )
635593 . no_stdout ( )
@@ -638,9 +596,7 @@ fn test_env_with_empty_executable_single_quotes() {
638596
639597#[ test]
640598fn test_env_with_empty_executable_double_quotes ( ) {
641- let ts = TestScenario :: new ( util_name ! ( ) ) ;
642-
643- ts. ucmd ( )
599+ new_ucmd ! ( )
644600 . args ( & [ "-S\" \" " ] ) // empty double quotes, considered as program name
645601 . fails_with_code ( 127 )
646602 . no_stdout ( )
@@ -858,8 +814,7 @@ fn test_env_arg_ignore_signal_valid_signals() {
858814#[ test]
859815#[ cfg( unix) ]
860816fn test_env_arg_ignore_signal_empty ( ) {
861- let ts = TestScenario :: new ( util_name ! ( ) ) ;
862- ts. ucmd ( )
817+ new_ucmd ! ( )
863818 . args ( & [ "--ignore-signal=" , "echo" , "hello" ] )
864819 . succeeds ( )
865820 . no_stderr ( )
0 commit comments