Skip to content

test: avoid same-size mtime race in step_commit_dry_run_stage_tracked - #2586

Merged
max-sixty merged 1 commit into
mainfrom
diagnose-flake
May 4, 2026
Merged

max-sixty merged 1 commit into
mainfrom
diagnose-flake

Conversation

@max-sixty

Copy link
Copy Markdown
Owner

The test wrote tracked.txt as "original" then "modified" — both 8 bytes. wt step commit --dry-run --stage=tracked runs git add -u against a copy of the index, so the only signal git has for the modification is mtime. On Linux/ext4 the recorded entry mtime and the post-modification mtime can be indistinguishable at the kernel's resolution; git treats the file as unchanged, the temp index keeps the old blob hash, and git diff --staged returns nothing. The rendered prompt then has empty <diffstat> / <diff> blocks and the assertion on "tracked.txt" / "modified" fires.

Reproduces 0/200 locally on macOS APFS and passes on test (linux), but flaked on the affected (linux, advisory) job for PR #2581 (logs) — that PR only touched PowerShell shell config and has no plausible effect on this code path.

Switching the modification to "modified content" makes the new size differ from the committed blob, so git's DATA_CHANGED check fires unconditionally and the test no longer depends on mtime resolution. This mirrors the adjacent test_step_commit_with_stage_tracked_flag (merge.rs:2113) which uses "initial" → "modified" (different sizes) for the same reason. PR #2433 fixed an analogous mtime-tick collision in the picker/summary tests.

The stdout.contains("modified") assertion still passes since "modified" is a prefix of the new content.

This was written by Claude Code on behalf of @max-sixty

Both "original" and "modified" are 8 bytes, so `git add -u` against the
dry-run temp index has only mtime to detect the change. On Linux/ext4 the
recorded entry mtime and the post-modification mtime can be indistinguishable
at the kernel's resolution, leaving the temp index pointing at the old blob
hash and producing an empty `git diff --staged`. The test then fails because
neither "tracked.txt" nor "modified" reach the rendered prompt — see PR
\#2581's advisory job for an example failure.

Use "modified content" so the file's size differs from the committed blob.
That trips git's DATA_CHANGED check unconditionally, removing the timing
dependency. Mirrors the adjacent `test_step_commit_with_stage_tracked_flag`
which uses "initial" -> "modified" (different sizes) for the same reason.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@max-sixty
max-sixty merged commit 5fb50b0 into main May 4, 2026
27 checks passed
@max-sixty
max-sixty deleted the diagnose-flake branch May 4, 2026 08:25
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