summaryrefslogtreecommitdiffstats
path: root/tests/by-util/test_ls.rs
diff options
context:
space:
mode:
authorDan Gohman <dev@sunfishcode.online>2023-04-25 05:14:09 -0700
committerDan Gohman <dev@sunfishcode.online>2023-04-25 05:40:37 -0700
commiteba000ddcc991bb168c80b8f7b60d8c51c745558 (patch)
tree8669e6b3286cab94b23f9b692d17329e626f0bfe /tests/by-util/test_ls.rs
parent0984097103b0656ca4dbb4ff2a5fb5eb674b103b (diff)
Use `expected_result` in test_ls to avoid spurious failures
As the existing comment says, the expected output here is dependent on the platform, so use the `expected_result` utility to avoid hard-coding specific results for each platform. This fixes spurious failures on my machine.
Diffstat (limited to 'tests/by-util/test_ls.rs')
-rw-r--r--tests/by-util/test_ls.rs14
1 files changed, 10 insertions, 4 deletions
diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs
index 1a189a25a..0779a2885 100644
--- a/tests/by-util/test_ls.rs
+++ b/tests/by-util/test_ls.rs
@@ -1,6 +1,6 @@
// spell-checker:ignore (words) READMECAREFULLY birthtime doesntexist oneline somebackup lrwx somefile somegroup somehiddenbackup somehiddenfile tabsize aaaaaaaa bbbb cccc dddddddd ncccc
-#[cfg(feature = "feat_selinux")]
+#[cfg(any(unix, feature = "feat_selinux"))]
use crate::common::util::expected_result;
use crate::common::util::TestScenario;
#[cfg(all(unix, feature = "chmod"))]
@@ -1776,9 +1776,15 @@ fn test_ls_order_time() {
at.open("test-4").metadata().unwrap().accessed().unwrap();
// It seems to be dependent on the platform whether the access time is actually set
- #[cfg(all(unix, not(target_os = "android")))]
- result.stdout_only("test-3\ntest-4\ntest-2\ntest-1\n");
- #[cfg(any(windows, target_os = "android"))]
+ #[cfg(unix)]
+ {
+ let expected = unwrap_or_return!(expected_result(&scene, &["-t", arg]));
+ at.open("test-3").metadata().unwrap().accessed().unwrap();
+ at.open("test-4").metadata().unwrap().accessed().unwrap();
+
+ result.stdout_only(expected.stdout_str());
+ }
+ #[cfg(windows)]
result.stdout_only("test-4\ntest-3\ntest-2\ntest-1\n");
}