Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Oct 23, 2023

Conversation

n1000
Copy link
Contributor

@n1000 n1000 commented Oct 23, 2023

  • 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

- 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
@n1000
Copy link
Contributor Author

n1000 commented Oct 23, 2023

Here is the specific coreutils documentation page I was referring to.

I wasn't sure how to test on android, so left the #cfg check in place for that target environment. For musl testing I used cargo test --target=x86_64-unknown-linux-musl test_test.

@sylvestre
Copy link
Contributor

Looks good :)
I am curious how you found this issue :)

@n1000
Copy link
Contributor Author

n1000 commented Oct 23, 2023

I am curious how you found this issue :)

I ended up finding this issue while running the tests on OpenBSD and digging into why this test case was failing. Eventually I found out OpenBSD was providing creation times of "0".. This led me to checking the OpenBSD "test" implementation and finding out that there both -nt and -ot used mtime.

Once I changed the uutils/coreutils "-ot" implementation to use the modified time, it was easier to spot that the -nt implementation on the line above was identical to "-ot" which raised a red flag.. 😃

@sylvestre sylvestre merged commit 209ffe8 into uutils:main Oct 23, 2023
44 of 45 checks passed
@n1000 n1000 deleted the test_ot_fix branch October 25, 2023 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants