1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

test: use mtime for -ot and fix direction of comparison

- Use the file modification time instead of the creation time (matches
  GNU coreutils documentation)

- Fix direction of comparison (a < b instead of a > b)

- Extend test case to cover both the 0 and 1 exit code cases
This commit is contained in:
Nathan Houghton 2023-10-22 10:51:15 -07:00
parent 03d598d08b
commit dbfd700502
2 changed files with 15 additions and 5 deletions

View file

@ -317,7 +317,7 @@ fn test_file_is_itself() {
}
#[test]
#[cfg(not(any(target_env = "musl", target_os = "android")))]
#[cfg(not(target_os = "android"))]
fn test_file_is_newer_than_and_older_than_itself() {
// odd but matches GNU
new_ucmd!()
@ -364,8 +364,7 @@ fn test_same_device_inode() {
}
#[test]
#[cfg(not(any(target_env = "musl", target_os = "android")))]
// musl: creation time is not available on this platform currently
#[cfg(not(target_os = "android"))]
fn test_newer_file() {
let scenario = TestScenario::new(util_name!());
@ -377,10 +376,21 @@ fn test_newer_file() {
.ucmd()
.args(&["newer_file", "-nt", "regular_file"])
.succeeds();
scenario
.ucmd()
.args(&["regular_file", "-nt", "newer_file"])
.fails();
scenario
.ucmd()
.args(&["regular_file", "-ot", "newer_file"])
.succeeds();
scenario
.ucmd()
.args(&["newer_file", "-ot", "regular_file"])
.succeeds();
.fails();
}
#[test]