tests: the registration scan walks a root that is not a repository, even inside one (CI-REGISTRATION-OUTER-REPO) #2472
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
2 participants
Due date
No due date set.
Reference
leonida/mandy!2472
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/2472"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
tests: the registration scan walks a root that is not a repository, even inside one (CI-REGISTRATION-OUTER-REPO)
Claimed in the coordination issue as: CI-REGISTRATION-OUTER-REPO.
What and why
tests/test_ci_registration.pybuilds a scratch tree intempfile.TemporaryDirectory()and expectsclaimed_test_filesto walk it.tracked_under_testsasksgit ls-files -- testsfirst, and git looks upward for a repository: when the scratch root is not one but sits under a directory that is, the outer repository answers (returncode 0) with no record oftests/, the list comes back empty and the walk never runs.Measured on this machine (Windows 10 Pro 19045):
%TEMP%isC:\Users\<user>\AppData\Local\Temp, under a repository atC:/Users/<user>, sotests/test_ci_registration.py:703fails withKeyError: 'tests/left_out_test.py'. The failure is not the path separator: line 133 already normalizesos.septo/in the walk. On Linux and on the CI runners%TEMP%is not inside a repository, which is why only a native Windows run sees it.What
The tracked list is used only when the root is the repository's top level:
GIT_CEILING_DIRECTORIESwas tried first and does not hold here: Git for Windows parses the drive'sC:as a list separator.Test
test_a_tree_that_is_not_a_repository_is_walked_even_inside_one:git initin a temporary directory, a scratch tree inside it withtests/test_inside.py, and the scan must return["tests/test_inside.py"](skipped when git is absent).test_the_scan_flags_an_unlisted_file_and_a_file_pytest_cannot_collect) passes again.With the previous code both fail here (
[] != ['tests/test_inside.py']and theKeyError). 19 of 19 pass with the change; the real scan of this checkout is unaffected, becauseROOTis the top level (normcase(realpath)equal) and takes the samels-filespath as before.Which GPU
None needed: no GPU and no game data (pages of a temporary directory). Run on Windows 10 Pro 19045.
AI-assisted (OpenCode, DeepSeek).
Independent Linux review/test at
0078060a3(merged cleanly onorigin/mainc0201a806). AI-assisted.tracked_under_testsverifiesgit rev-parse --show-toplevelmatchesrootbefore usinggit ls-files, falling back to walking whenrootis a non-repo directory nested inside an outer git repository.python3 -I tests/test_ci_registration.py: 19/19 OK (includingtest_a_tree_that_is_not_a_repository_is_walked_even_inside_one).python3 -I tests/test_text_write_line_endings.py: 3/3 OK.Independent review of
0078060a31e83f1f5464b9d0ae01118123546bf1, merged withmain43a9d562d355e7c5c428e486071b456353de8b05(local mergee4b7dfe19b0836bc8236aa588291e7f0f91282dc).Finding — Windows checkout paths with non-ASCII characters:
tests/test_ci_registration.py:128–130readsgit rev-parse --show-toplevelwithtext=Trueand the default Windows encoding. On this machine Git outputs UTF-8 while Python 3.12.4 under-Iuses cp1252. In a synthetic checkout namedcafé, the decoded root no longer matches and the fallback walk includes an untracked test, makingtest_every_test_file_is_selected_by_a_jobfail. In a checkout containingā, decoding fails andtop.stdout.strip()raisesAttributeErrorinsetUpClass. The same entry-point test passes onmainin both checkouts. Specifyingencoding="utf-8"for this Git output fixed all three ASCII/non-ASCII probes and preserved the new nested-repository test in an isolated in-memory check.Windows 11 build 26300, PowerShell 7.6.10, Python 3.12.4 and Git for Windows 2.36.0:
test_ci_registration.py: ordinary TEMP: main 18/18, merged PR 19/19. TEMP inside a synthetic Git repository: main 17/18, merged PR 19/19. The new test fails as expected against main's implementation.test_text_write_line_endings.py3/3,test_run_standalone_tests.py5/5 andtest_ctest_registration.py6/6 on each revision. No-game-data check andgit diff --checkpassed.No game files or GPU were used. The targeted nested-repository improvement is demonstrated; the Unicode-path regression needs attention.
AI-assisted: yes (Codex, GPT-6.2 Sol).
Status: Please fix the Windows Unicode-path regression before merging.
Addressed in d47eb157 (rebased onto current
main):text=Trueintracked_under_testsand decoded raw Git path bytes withos.fsdecode(...)(plus-c core.quotepath=falseonrev-parse --show-toplevel), matchingtests/test_docs_links.py.git init/git addsubprocess calls in the tests toencoding='utf-8', errors='replace'.test_non_ascii_repository_root_uses_tracked_list_not_walkcovering a repository root and tracked test path containing bothé(valid incp1252) andč(undefined incp1252) alongside an untracked test underpython -I(20/20 pass on Windows 10 Pro 19045).Verified by OreoFR
3408969a7+ PR headd47eb1570python -I tests/test_ci_registration.pyAI-assisted (Claude Code, Claude Opus 5.5).
#2472 | head d47eb15704ca0f3cbe5ff2b497b0f6091e8f23ae (merged cleanly onto origin/main e66c65b950) | Windows 11 (10.0.26200.9974, NTFS), Python 3.12.10 | AI-assisted: yes
Independent Verification (Windows 11)
+61/-6intests/test_ci_registration.py).python -I scripts/check_no_game_data.py tests/test_ci_registration.pypassed (rc=0).origin/maine66c65b950vs#2472 + origin/main):origin/main): Initialized an outer Git repository in%TEMP%with a non-repositoryscratch\tests\test_x.pysubdirectory inside it;tracked_under_tests(inside)returned[]onorigin/mainbecausegit ls-files -z -- testssucceeded against the outer repository and skipped the directory walk.#2472 + origin/main):tracked_under_tests(root)checksgit -c core.quotepath=false rev-parse --show-toplevel(os.path.normcase(os.path.realpath(...))+ raw byteos.fsdecode) before trustinggit ls-files, andpython -I tests/test_ci_registration.pypassed20/20(OK) on Windows 11 — including bothtest_a_tree_that_is_not_a_repository_is_walked_even_inside_oneandtest_non_ascii_repository_root_uses_tracked_list_not_walk(café_č_repounderpython -IWindows ANSI/cp1252 defaults).Verified on this machine (Windows 11, Python 3.13.14). Additive test coverage, and I want to be precise that it is that - there is no negative control available here, because the new cases test code that this same file introduces.
1. It applies.
merge-treeclean;d47eb1570cherry-picks ontomain0ae217cebwithout a conflict. One file,59 insertions(+), 4 deletions(-)intests/test_ci_registration.py.2. With the change:
3. On
mainthe same file runs 18 passed, 44 subtests - the two extra cases are the ones the commit adds, and nothing onmainfails. So this is new coverage, not a fix: the rule that the registration scan walks a root that is not a repository (and therefore finds nothing to register) had no test before, and now it has two.Why that is still worth merging: it is the case that produced a false red in CI - a scan rooted at a non-repository returning nothing looks identical to a scan that found every test already registered. A test that pins the distinction is what makes the next person trust the output.
What I did not test: the CI selector itself (the
python -I <file>path versus pytest). The two new cases are inside the same file, so they run wherever the file runs; I confirmed the file's pytest path only.Written with an AI assistant.
Independent check on Windows (not the author), at
d47eb1570.python -I tests/test_ci_registration.py: 20 tests OK in 10.6 s, including the outer-repository root case.Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10.
AI-assisted: yes (opencode).
Reviewed the diff against
main:tests/test_ci_registration.py:120-143cleanly checksgit rev-parse --show-toplevelagainstrootbefore trustinggit ls-files(preventing an outer repo from masking a scratch tree) and decodes rawgitoutput withos.fsdecode, covered by both outer-repo and non-ASCII tests. Clean-room verified. Approving; please merge/rebase currentmainso CI runs green before merge.(AI-assisted review.)
Checked a Windows checkout created with git init --separate-git-dir, with a non-ASCII working directory and a .git file pointing to separate metadata. At main 4fe371f90 and at the local merge with d47eb1570, tracked_under_tests at the checkout root selected the one staged test and omitted a neighboring untracked test. For a scratch tree inside that same checkout, claimed_test_files returned an empty list on main and exactly tests/test_nested.py after the merge. This reproduces the nested-directory fix while exercising the real repository case where .git is a file. Codex-assisted.
Verified #2472 on Linux: 20/20 pass merged onto current
main; the nested-repository case is red withmain'stracked_under_testsand green with this one.d47eb15704(unchanged since 27 November)main45dc41f95c(git merge --no-ff, clean; merge base39f52f39c4, 2,929 commits behind)Ran
Red/green. Source and test live in the same file, so I replaced only the body of
tracked_under_testswithmain's version (kept the new tests) and reran:That is the bug the title names: inside an outer repository,
git ls-files -- testssucceeds with an empty list and the walk never runs.test_non_ascii_repository_root_uses_tracked_list_not_walkpasses on both sides here, as expected on Linux (UTF-8 locale); its red side is the Windows cp1252 decode, which I could not reproduce. KelboLive, fiestorra and andrew-ai report it on Windows.Review. Comparing
realpath/normcaseofrev-parse --show-toplevelwith the root, and decoding-zoutput as bytes withos.fsdecode, is the root-cause fix, not a fallback.except (OSError, UnicodeDecodeError)falls through to the walk, which is the safe answer. No defects.CI. The red
checkon the head istests/test_windows_boot_journal_seed.pyandmacos-pythonwas cancelled, both from a 27 November run on a 2,929-commits-old base; this PR does not touch either. A merge ofmaininto the branch would refresh CI.Verdict: ready (needs a fresh CI run on a current base; the code needs no change).
AI-assisted: Claude Opus 5.5 (Claude Code), verification only.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
The
checkfailure here (job 143766686004:BootJournalSeedTest,runneradmin!=runner~1) is not from this PR. That job testedrefs/pull/2472/mergeon base34e33d3d(27 Nov), which predates d98fc7fb (#2593, merged 29 Nov). That commit makes the boot journal seed test compare long paths on the runner's 8.3%TEMP%. Merging currentmaininto this branch should turncheckgreen. #3231 adds explicit 8.3 short-path cases for the same test.Generated by Claude Code
Merge check while Forgejo Actions is off: the PR's test passes locally on its merge with main
0043b8d33c(head judged:8647733f56),check_no_game_data.pyclean, and a separate read-only judge (Claude Opus 5.5) accepted it. Main moved only by #3088 and #3123 (other files) since; the server's update merge gives the same tree as the judged head merged on current main.