From 560cd74a639157e85b256542ce9a867d30daf377 Mon Sep 17 00:00:00 2001 From: Hanif Bin Ariffin Date: Wed, 2 Feb 2022 12:49:40 +0800 Subject: [PATCH] test_ls: Do not rely on the system time of metadata'access time Signed-off-by: Hanif Bin Ariffin --- tests/by-util/test_ls.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index e3fd99e00..f61611390 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1327,17 +1327,14 @@ fn test_ls_order_time() { // So the order should be 2 3 4 1 for arg in &["-u", "--time=atime", "--time=access", "--time=use"] { let result = scene.ucmd().arg("-t").arg(arg).succeeds(); - let file3_access = at.open("test-3").metadata().unwrap().accessed().unwrap(); - let file4_access = at.open("test-4").metadata().unwrap().accessed().unwrap(); + at.open("test-3").metadata().unwrap().accessed().unwrap(); + at.open("test-4").metadata().unwrap().accessed().unwrap(); // It seems to be dependent on the platform whether the access time is actually set - if file3_access > file4_access { - result.stdout_only("test-3\ntest-4\ntest-2\ntest-1\n"); - } else { - // Access time does not seem to be set on Windows and some other - // systems so the order is 4 3 2 1 - result.stdout_only("test-4\ntest-3\ntest-2\ntest-1\n"); - } + #[cfg(unix)] + result.stdout_only("test-3\ntest-4\ntest-2\ntest-1\n"); + #[cfg(windows)] + result.stdout_only("test-4\ntest-3\ntest-2\ntest-1\n"); } // test-2 had the last ctime change when the permissions were set