@@ -2254,24 +2254,29 @@ fn test_ls_order_time() {
22542254 let result = scene. ucmd ( ) . arg ( "--sort=time" ) . arg ( "-r" ) . succeeds ( ) ;
22552255 result. stdout_only ( "test-1\n test-2\n test-3\n test-4\n " ) ;
22562256
2257+ let args: [ & [ & str ] ; 10 ] = [
2258+ & [ "-t" , "-u" ] ,
2259+ & [ "-u" ] , //-t is optional: when -l is not set -u/--time controls sorting
2260+ & [ "-t" , "--time=atime" ] ,
2261+ & [ "--time=atime" ] ,
2262+ & [ "--time=atim" ] , // spell-checker:disable-line
2263+ & [ "--time=a" ] ,
2264+ & [ "-t" , "--time=access" ] ,
2265+ & [ "--time=access" ] ,
2266+ & [ "-t" , "--time=use" ] ,
2267+ & [ "--time=use" ] ,
2268+ ] ;
22572269 // 3 was accessed last in the read
22582270 // So the order should be 2 3 4 1
2259- for arg in [
2260- "-u" ,
2261- "--time=atime" ,
2262- "--time=atim" , // spell-checker:disable-line
2263- "--time=a" ,
2264- "--time=access" ,
2265- "--time=use" ,
2266- ] {
2267- let result = scene. ucmd ( ) . arg ( "-t" ) . arg ( arg) . succeeds ( ) ;
2271+ for args in args {
2272+ let result = scene. ucmd ( ) . args ( args) . succeeds ( ) ;
22682273 at. open ( "test-3" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
22692274 at. open ( "test-4" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
22702275
22712276 // It seems to be dependent on the platform whether the access time is actually set
22722277 #[ cfg( unix) ]
22732278 {
2274- let expected = unwrap_or_return ! ( expected_result( & scene, & [ "-t" , arg ] ) ) ;
2279+ let expected = unwrap_or_return ! ( expected_result( & scene, args ) ) ;
22752280 at. open ( "test-3" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
22762281 at. open ( "test-4" ) . metadata ( ) . unwrap ( ) . accessed ( ) . unwrap ( ) ;
22772282
@@ -2287,6 +2292,10 @@ fn test_ls_order_time() {
22872292 {
22882293 let result = scene. ucmd ( ) . arg ( "-tc" ) . succeeds ( ) ;
22892294 result. stdout_only ( "test-2\n test-4\n test-3\n test-1\n " ) ;
2295+
2296+ // When -l is not set, -c also controls sorting
2297+ let result = scene. ucmd ( ) . arg ( "-c" ) . succeeds ( ) ;
2298+ result. stdout_only ( "test-2\n test-4\n test-3\n test-1\n " ) ;
22902299 }
22912300}
22922301
0 commit comments