fix: GNU-first stat in file_mtime() to unbreak GNU/Linux CI (#245)#246
Merged
Conversation
idd-tree-lock file_mtime() tried BSD `stat -f %m` first. On GNU/Linux `-f` is --file-system, so it leaks a multi-line filesystem block into holder_is_live()`s freshness arithmetic; a fresh empty lock is then wrongly reclaimed instead of held. That broke the f8 fixture only on the Linux CI runner (green on macOS), leaving main red. Swap to GNU-first `stat -c %Y || stat -f %m`: on Linux the first form succeeds and short-circuits (no fs garbage); on BSD/macOS `-c` is illegal -> clean rc=1 empty stdout -> falls through to `-f %m`. Add regression fixture f11 that PATH-shims a GNU-semantics stat so the Linux-only failure is now reproducible on any host (RED before, GREEN after). Full suite 21/21. Refs #245
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
CI is red on
main: theidd-tree-lockfixture suite fails on the GNU/Linuxrunner (green on macOS) —
A red
mainobscures the CI signal for every future PR, so this is thehighest-priority fix in the backlog.
Root cause — BSD-first
statbreaks on GNU/Linuxscripts/idd-tree-lock.shfile_mtime()tried BSD syntax first:The two
statdialects read the flags incompatibly:-f%m= mtime)--file-system(prints multi-line fs status)-c%Y= mtime)On Linux,
stat -f %m "$LOCK"is parsed as--file-systemand prints thelock's multi-line filesystem block to stdout.
file_mtime()therefore returns"<multi-line fs garbage>\n<real mtime>", which corruptsholder_is_live()'sfreshness arithmetic (
age=$(( now - mtime ))on a multi-line string fails →holder judged "not live" → a fresh empty lock is wrongly reclaimed instead
of held). Hence
expected exit 3 got 1.Fix
Try GNU-first, which resolves cleanly on both platforms:
stat -c %Ysucceeds → bare integer,||short-circuits (no fs garbage ever produced).stat -c %Yfails cleanly (illegal option, no stdout — verifiedrc=1, empty stdout) →||falls through tostat -f %m→ correct mtime.Test — RED/GREEN regression
New fixture f11 PATH-shims a GNU-semantics
statso the Linux-only failurereproduces on any host: RED with the BSD-first order (reproduces the exact
expected exit 3 got 1symptom on macOS), GREEN after the swap.idd-tree-lock20 PASS / 1 FAIL (f11).idd-tree-lock21 PASS / 0 FAIL.run-all-tests.sh): 21 suites, 0 failed.Verification
bash plugins/issue-driven-dev/scripts/run-all-tests.sh→ 21 suites, 0 failed (local macOS)Refs #245