find: match GNU rounding for -amin/-cmin/-mmin - #841
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #841 +/- ##
==========================================
+ Coverage 92.15% 92.17% +0.01%
==========================================
Files 35 35
Lines 7377 7408 +31
Branches 383 385 +2
==========================================
+ Hits 6798 6828 +30
Misses 438 438
- Partials 141 142 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Commit ddd2b65 has test result changes: bfs testsuite: |
|
The bfs job flags Same tree bfs's test builds (files at -3600s, -121s, -61s, -30s, +60s, +3600s), run against GNU findutils 4.11, bfs 4.1.4, and this branch: The bfs rows are exactly what Happy to add these two to (Reposting: my earlier comment had stray backslashes from a shell quoting slip.) |
The age in minutes was computed with a truncating division, so a file accessed a few seconds ago landed in bucket 0 and '-amin 1' missed it. GNU puts an age of d seconds in bucket d/60 + 1, and compares '-amin -n' and '-amin +n' against n*60 seconds directly, which is a different off-by-one from the exact case. Compare against the age in seconds so all three forms follow GNU. Closes uutils#813
ddd2b65 to
5a03048
Compare
|
Commit 5a03048 has test result changes: bfs testsuite: |
Fixes #813.
-amin/-cmin/-mmincomputed the age in minutes with a truncating division, so a file accessed a few seconds ago landed in bucket 0 andfind -amin 1didn't list it, while GNU does.I checked the actual behaviour against GNU findutils 4.11 rather than guessing, and it turns out the three comparator forms don't share one rounding rule:
-amin nmatches when(n-1)*60 <= age < n*60, i.e. an age ofdseconds falls in bucketd/60 + 1-amin -nmatches whenage < n*60-amin +nmatches whenage >= n*60Feeding a single
age_in_minutesintoComparableValuecan't express all three at once (whichever value you pick, one of the forms is off by one), so the comparison is now done against the age in seconds directly.Verified against GNU on files aged 0/30/59/60/61/90/119/120/121/179/180/181 seconds — output is now identical for
-mminwith 0, 1, 2, 3, -1, -2, +0, +1 and +2. Added a unit test pinning those boundaries; the two existingfile_age_range_matcherassertions still pass unchanged.