test(update): make EOL-churn dirtiness deterministic under racy-git stat caching

test_churn_across_more_files_than_fit_in_one_argv (e65ff9625f) asserts all
1200 checked-out files read dirty before normalization. Whether git diff
content-compares an entry (seeing the CRLF churn) or trusts the stat cache
depends on racy-git detection: entries whose recorded stat is non-racy
(mtime older than the index write) read CLEAN. On CI a 1200-file checkout
straddles that boundary nondeterministically — observed 92/1200 and
661/1200 dirty on two unrelated PRs within minutes (runs 30738759530,
30738842393). Empirically reproduced: freezing a non-racy stat cache gives
0/N dirty; bumping worktree mtimes past the index write forces content
comparison and gives N/N deterministically.

Fix: bump every worktree mtime after checkout in _managed_repo so all
entries are stat-stale. Affects only the fixture; the production
_normalize_managed_eol path is untouched.
This commit is contained in:
Teknium 2026-08-02 01:07:00 -07:00
parent 45c15d33e5
commit fe497d8722
1 changed files with 13 additions and 0 deletions

View File

@ -59,6 +59,19 @@ def _managed_repo(tmp_path: Path, files: dict[str, bytes]) -> Path:
for name in files:
(repo / name).unlink()
_git(repo, "checkout", "--", ".")
# Deterministic dirtiness: whether `git diff` content-checks an entry (and
# so sees the CRLF churn) or trusts the stat cache depends on racy-git
# detection — entries whose mtime equals the index timestamp get content-
# compared, later ones read clean. On a fast runner a large checkout
# straddles that boundary nondeterministically (CI flake: 92/661 of 1200
# dirty). Bump every worktree mtime past the index write so ALL entries
# are stat-stale and git must content-compare each one.
import os as _os
import time as _time
bumped = _time.time() + 5
for name in files:
_os.utime(repo / name, (bumped, bumped))
return repo