From fe497d8722eb43780ada1185db6d4012f65de885 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 2 Aug 2026 01:07:00 -0700 Subject: [PATCH] test(update): make EOL-churn dirtiness deterministic under racy-git stat caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- tests/hermes_cli/test_update_eol_churn.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/hermes_cli/test_update_eol_churn.py b/tests/hermes_cli/test_update_eol_churn.py index fb742d8001dd3..a8fe2f762f514 100644 --- a/tests/hermes_cli/test_update_eol_churn.py +++ b/tests/hermes_cli/test_update_eol_churn.py @@ -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