@@ -12,20 +12,7 @@ use std::{
1212 process:: { Command , Output , Stdio } ,
1313} ;
1414
15- use plib:: testing:: { run_test, TestPlan } ;
16-
17- fn time_test ( args : & [ & str ] , expected_output : & str , expected_error : & str , expected_exit_code : i32 ) {
18- let str_args: Vec < String > = args. iter ( ) . map ( |s| String :: from ( * s) ) . collect ( ) ;
19-
20- run_test ( TestPlan {
21- cmd : String :: from ( "time" ) ,
22- args : str_args,
23- stdin_data : String :: new ( ) ,
24- expected_out : String :: from ( expected_output) ,
25- expected_err : String :: from ( expected_error) ,
26- expected_exit_code,
27- } ) ;
28- }
15+ use plib:: TestPlan ;
2916
3017fn run_test_base ( cmd : & str , args : & Vec < String > , stdin_data : & [ u8 ] ) -> Output {
3118 let relpath = if cfg ! ( debug_assertions) {
@@ -63,7 +50,7 @@ fn get_output(plan: TestPlan) -> Output {
6350 output
6451}
6552
66- fn run_test_time_error_only (
53+ fn run_test_time (
6754 args : & [ & str ] ,
6855 expected_output : & str ,
6956 expected_error : & str ,
@@ -85,45 +72,22 @@ fn run_test_time_error_only(
8572 assert ! ( stderr. contains( expected_error) ) ;
8673}
8774
88- #[ test]
89- fn test_smoke_help ( ) {
90- time_test (
91- & [ "--help" ] ,
92- "\
93- time - time a simple command or give resource usage
94-
95- Usage: time [OPTIONS] <UTILITY> [ARGUMENT]...
96-
97- Arguments:
98- <UTILITY> The utility to be invoked
99- [ARGUMENT]... Arguments for the utility
100-
101- Options:
102- -p, --posix Write timing output to standard error in POSIX format
103- -h, --help Print help
104- -V, --version Print version
105- " ,
106- "" ,
107- 0 ,
108- ) ;
109- }
110-
11175#[ test]
11276fn simple_test ( ) {
113- run_test_time_error_only ( & [ "--" , "ls" , "-l" ] , "" , "User time" , 0 ) ;
77+ run_test_time ( & [ "--" , "ls" , "-l" ] , "" , "User time" , 0 ) ;
11478}
11579
11680#[ test]
11781fn p_test ( ) {
118- run_test_time_error_only ( & [ "-p" , "--" , "ls" , "-l" ] , "" , "user" , 0 ) ;
82+ run_test_time ( & [ "-p" , "--" , "ls" , "-l" ] , "" , "user" , 0 ) ;
11983}
12084
12185#[ test]
12286fn parse_error_test ( ) {
123- run_test_time_error_only ( & [ ] , "" , "not provided" , 0 ) ;
87+ run_test_time ( & [ ] , "" , "not provided" , 0 ) ;
12488}
12589
12690#[ test]
12791fn command_error_test ( ) {
128- run_test_time_error_only ( & [ "-s" , "ls" , "-l" ] , "" , "unexpected argument '-s' found" , 0 ) ;
92+ run_test_time ( & [ "-s" , "ls" , "-l" ] , "" , "unexpected argument '-s' found" , 0 ) ;
12993}
0 commit comments