@@ -2076,24 +2076,29 @@ fn test_ls_order_time() {
20762076 let result = scene. ucmd ( ) . arg ( "--sort=time" ) . arg ( "-r" ) . succeeds ( ) ;
20772077 result. stdout_only ( "test-1\n test-2\n test-3\n test-4\n " ) ;
20782078
2079+ let args: [ & [ & str ] ; 10 ] = [
2080+ & [ "-t" , "-u" ] ,
2081+ & [ "-u" ] , //-t is optional: when -l is not set -u/--time controls sorting
2082+ & [ "-t" , "--time=atime" ] ,
2083+ & [ "--time=atime" ] ,
2084+ & [ "--time=atim" ] , // spell-checker:disable-line
2085+ & [ "--time=a" ] ,
2086+ & [ "-t" , "--time=access" ] ,
2087+ & [ "--time=access" ] ,
2088+ & [ "-t" , "--time=use" ] ,
2089+ & [ "--time=use" ] ,
2090+ ] ;
20792091 // 3 was accessed last in the read
20802092 // So the order should be 2 3 4 1
2081- for arg in [
2082- "-u" ,
2083- "--time=atime" ,
2084- "--time=atim" , // spell-checker:disable-line
2085- "--time=a" ,
2086- "--time=access" ,
2087- "--time=use" ,
2088- ] {
2089- let result = scene. ucmd ( ) . arg ( "-t" ) . arg ( arg) . succeeds ( ) ;
2093+ for args in args {
2094+ let result = scene. ucmd ( ) . args ( args) . succeeds ( ) ;
20902095 at. open ( "test-3" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
20912096 at. open ( "test-4" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
20922097
20932098 // It seems to be dependent on the platform whether the access time is actually set
20942099 #[ cfg( unix) ]
20952100 {
2096- let expected = unwrap_or_return ! ( expected_result( & scene, & [ "-t" , arg ] ) ) ;
2101+ let expected = unwrap_or_return ! ( expected_result( & scene, args ) ) ;
20972102 at. open ( "test-3" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
20982103 at. open ( "test-4" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
20992104
@@ -2109,6 +2114,10 @@ fn test_ls_order_time() {
21092114 {
21102115 let result = scene. ucmd ( ) . arg ( "-tc" ) . succeeds ( ) ;
21112116 result. stdout_only ( "test-2\n test-4\n test-3\n test-1\n " ) ;
2117+
2118+ // When -l is not set, -c also controls sorting
2119+ let result = scene. ucmd ( ) . arg ( "-c" ) . succeeds ( ) ;
2120+ result. stdout_only ( "test-2\n test-4\n test-3\n test-1\n " ) ;
21122121 }
21132122}
21142123
0 commit comments