Repository navigation
Merged
Conversation
…-recursively
`_fixture_files()` used `FIXTURES_DIR.iterdir()`, which only ever sees the
immediate children of tests/fixtures/, so a real /Users/<x>/ or /home/<x>/
segment committed inside a subdirectory would be invisible to the detector
at any depth. The detector's own positive control (`>= 2` file count)
could not have caught this: it is satisfied by the top-level files alone,
which is exactly why the issue's own MUST-FIRE case had to be planted at
the top level to pass.
Switched to `FIXTURES_DIR.rglob("*")`, and added:
- a MUST-FIRE case proving the enumeration itself now descends into a
synthetic subdirectory (the real tests/fixtures/ has none today, so a
synthetic tree is the only way to exercise depth at all)
- a MUST-FIRE case driving a nested #467-shaped home path through the
real detector logic end to end, not just the bare regex
- a MUST-NOT-FIRE case proving the widened walk does not start firing on
the sanitised placeholder segment at that same depth
- a receipt test that cross-checks the number of files the scan examined
against `git ls-files tests/fixtures`, so a walk that silently drops a
subtree disagrees with a number instead of passing quietly (the fix
note in #480 asked for recursion plus this)
Scope: tests/test_no_real_home_paths_467.py only.
Co-Authored-By: Max <noreply>
…sts/fixtures/ Review of the prior commit (e77b27d) caught it: the receipt test added for #480 compared `len(_fixture_files())` against `len(git ls-files tests/fixtures)` for exact equality. `rglob("*")` walks the filesystem, not the git index, so a file that exists on disk but is not tracked -- reproduced with a stray `.DS_Store`, which is `.gitignore`d in this repo but still visible to the walk -- makes the counts disagree for a reason that has nothing to do with a missed subtree. A contributor who has ever opened tests/fixtures/ in Finder on macOS could hit this locally. Switched to a subset check: every git-tracked file under tests/fixtures/ must be present in what the walk found, without demanding the walk find nothing else. That still catches the #480 regression (a dropped subtree drops tracked files from the walk's result) and stops asserting against files nobody tracks. Reproduced both directions: `touch tests/fixtures/.DS_Store` no longer fails the suite; the file still fails if a tracked fixture goes missing from the walk's output. Co-Authored-By: Max <noreply>
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.
Closes #480.
Detector 1 of the #467 home-path guard (
tests/test_no_real_home_paths_467.py) enumeratedtests/fixtures/withFIXTURES_DIR.iterdir(), which only ever sees the immediate children of that directory. A real/Users/<x>/or/home/<x>/segment committed inside a subdirectory oftests/fixtures/would be invisible to the detector at any depth, and its own positive control (test_scanned_at_least_one_fixture_file, assertinglen(files) >= 2) could not have noticed -- it is satisfied by the 4 top-level files alone, which is exactly why the issue's own MUST-FIRE fixture had to sit at the top level to pass.Fix:
_fixture_files()now walks withFIXTURES_DIR.rglob("*")filtered byis_file().New tests, all pointing the scan at a synthetic tree via
monkeypatch.setattr(f"{__name__}.FIXTURES_DIR", tmp_path)since the realtests/fixtures/has no subdirectories today and cannot exercise depth on its own:test_fixture_scan_descends_into_subdirectories-- MUST FIRE, the enumeration alonetest_detector_fires_on_a_home_path_nested_in_a_fixture_subdirectory-- MUST FIRE, the full detector end to end, at depthtest_detector_does_not_fire_on_a_sanitised_path_in_a_fixture_subdirectory-- MUST NOT FIRE, the paired negative control at the same depthtest_fixture_scan_reports_how_many_files_it_examined-- the receipt half of the issue's own fix note ("recursion plus a receipt naming how many files were actually examined, so an empty walk cannot read as a clean one")Red before the fix (
2 failed, 1 passed, 9 deselected), green after (12 passed).Review round 1 finding, fixed in a second commit. Both the spawned reviewer and the spawned auditor independently caught the same issue in the first commit: the receipt test compared
len(files) == len(git ls-files tests/fixtures)for exact equality.rglob("*")walks the filesystem, not the git index, so a file that physically exists undertests/fixtures/but isn't tracked -- a stray.DS_Store,.gitignored in this repo but created by Finder just from browsing the folder -- would make the walk's count disagree with git's count for a reason unrelated to any missed subtree. Reproduced (touch tests/fixtures/.DS_Store->AssertionError: fixture scan examined 5 file(s) but git tracks 4), then fixed by switching to a subset check: every git-tracked file undertests/fixtures/must be present in what the walk found, without demanding the walk find nothing else -- still catches a dropped subtree, no longer trips on an untracked stray file. Re-verified both directions.BELOW-BAR NOTE: none raised in this round; both review findings were fixed in-scope.
Docs:
README.md(this repo's onlydocs_targetsentry) opened; it describestests/fixtures/codex-rollout.jsonlonly in an unrelated paragraph about #443 and says nothing about the guard's own internals -- no-change-needed. Changelog fragment added atchangelog.d/480.fixed.md, checked with.oss/assemble_changelog.py --check(ok).Scope:
tests/test_no_real_home_paths_467.pyandchangelog.d/480.fixed.mdonly, per the brief -- no touch topipeline/,scripts/user-prompt-hook.sh,scripts/save-session.shorscripts/session-end-hook.sh, which other concurrent lanes hold.Verified by the maintainer
Independent of the lane, at review of this pull request. The report's
platformfield isnulland the body says nothing about the cross-platform dimension the brief asked for, so I read the file rather than leave that unanswered.The platform question does not bite, and the reason is worth stating.
_HOME_PATH = re.compile(r"(?:/Users/|/home/)([A-Za-z0-9_.-]+)")is matched against file contents, not against filesystem paths -- the detector scans the committed bytes of each fixture, which carry whatever separators they were captured with, independent of the host reading them.rglob("*")plusis_file()is separator-neutral, andrelative_to(REPO_ROOT)appears only in offender messages. So the widened walk behaves identically on a backslash-separated host. That claim is reasoned from reading the code, not observed on Windows -- and this detector cannot be observed there, per the next point.The thing a reviewer should actually know about this guard: it does not run on CI at all. The file's own argued correction (lines 78-100) records why --
windows-latestruns asrunneradmin, which appears legitimately intests/test_stale_config_sweep_362.pyas a realistic Windows home-path fixture, and #472 turned the CI pass into a live false positive. A per-image skiplist was rejected as wrong-by-construction on the next image. That is a deliberate, well-argued scope decision, not an oversight -- but it means this fix widens a detector whose only execution is local. The matrix will not exercise the recursion this pull request adds; a maintainer runningpytestwill.Accepted as reported: the red run (
2 failed, 1 passed), the depth-paired MUST-FIRE / MUST-NOT-FIRE, and the review round that caught the receipt test's exact-count comparison againstgit ls-filesand moved it to a subset check. I did not re-run the suite; the lane's own module run is green and CI is the gate for the rest.