tests: rename the address-guard unit test so discovery stops importing two test_address_guard modules #2903
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2903"
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?
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T16:55:19Z.
What and why
python -m pytest tests/andpython -m unittest discover -s testsboth fail on currentmainbecause two test modules share a basename:Discovery imports one as
test_address_guardand then refuses the other (import file mismatchfor pytest;module incorrectly imported from …for unittest). Onmain85ec1d33b:The two files are not duplicates — the top-level one is the stdlib oracle for
tools/address_guard.py(7 tests), the semantic one is the end-to-endrdna2spirv.py --address-guardtest (12 tests) — so the fix is a rename, not a merge.This renames only the top-level file to
tests/test_address_guard_oracle.py(R100, zero content change). That name matches its role and itsAddressGuardOracleTestclass, and it needs no reference updates: the three references in the tree (docs/design.md:384,docs/d3d12_vulkan.md:2095,runtime/src/address_guard.h:22) all point at the semantic path.Evidence
On this branch (same tree otherwise), Windows 11 / Python 3.12:
python -m pytest tests/semantic/is unchanged, and the rename works whether or not #2869'stests/semantic/__init__.pylands (that fixes pytest collection only;unittest discoverstill fails on the collision).Tested
The four commands above, plus
tests/test_ci_registration.py,test_test_inventory.py,test_docs_links.py,test_docs_repo_paths.py(47 tests) andpython -I scripts/check_no_game_data.pyon the renamed file. The full semantic suite is 554 files / 6,743 tests, 0 failed.Notes
git merge-treeagainst currentmainis clean.AI-assisted: yes
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T18:04:12Z.
Independent discovery comparison for the two rename approaches at
27613ab6b, CPython 3.14.10 and pytest 9.2.0 on Linux.pytest tests/ --collect-only -qfound 19,388 tests and thetest_address_guardimport mismatch on main. With this PR (5d778207) it collected 19,395 and exited 0.unittest.TestLoader.discover("tests")raised the same basename collision on main and found 10,624 tests with zero loader errors on this PR. Standalone execution of the two files passed all 7 oracle and 12 semantic tests.For comparison, the current #2869 head
3c4fc452renames the semantic file and produced the same clean discovery counts and standalone results.I also combined this PR with #2905 (
74da6c8a4). It kept both clean discovery counts. Under CPython 3.14.7, the scopedtest_support_installs_the_finder_only_where_the_tokenizer_is_slowstill fails with the rename alone, and passes with #2905 alone and with the combination. That distinguishes the two collection and import-order problems.MEASURED with synthetic test inputs. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-01T18:05:49Z.
Verified on Windows 11, Python 3.13.12. pytest is not installed on this machine, so this covers the
unittesthalf only.Discovery only (
unittest.TestLoader().discover("tests"), which imports every module without running the tests):maind2a564b66ImportError: 'test_address_guard' module incorrectly imported from ...\tests\semantic. Expected ...\tests5d778207aOn the PR, discovery records 31 load errors. 30 are
ModuleNotFoundError: No module named 'pytest', and the last is'NoneType' object has no attribute 'mark', a pytest marker used without pytest. All of them come from this machine not having pytest. None of them involve the two address-guard files.The renamed file still runs on its own:
python -I tests/test_address_guard_oracle.py -vgives 7 tests, OK. Running it as-m unittest test_address_guard_oraclefrom insidetests/with-Icannot find it, but that is-Idropping the current directory, not the rename.Not checked:
pytest tests/ --collect-only, the other half of the description.GPUs tested: n/a.
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T18:15:47Z.
Rebased onto current
main(7fbdf8511) and re-measured, since the tree moved ~50 commits since this was opened:So the collision is still live on main and the rename still resolves both commands. The branch is now 0 commits behind; force-pushed as
eb4bedce6(one file, zero content change).CI still shows no workflow runs for this head — same fork approval gate as before, nothing on our side can start them.
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T18:21:29Z.
One scope note, since the deprecation sweep is closing legacy-Python PRs: this one is not a change to the legacy shader compiler's behaviour. It renames a test file so that repo-wide test discovery works at all —
pytest tests/andpython -m unittest discover -s testsboth abort onmaintoday because two modules are both namedtest_address_guard, and the collision takes down collection of the wholetests/tree (including thed3d12/suites), not just the address-guard tests. Zero content change, no game data.If you would rather the address-guard oracle go away with the legacy compiler, that is a different change (deleting the file and its semantic sibling), and I am happy to prepare it — but until then, main cannot run either discovery command. Flagging so it is not closed as legacy by reflex; if you still consider it out of scope, close it and I will not reopen.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T19:26:33Z.
Discovery recheck of the rebased rename and import-order combination at
4afb7131on current main93ffc482, with and without #2905 (74da6c8a). I used CPython 3.14.7 and 3.14.10 with pytest 9.2.0, NumPy 2.5.5, and Pillow 13.0.0. On each Python version, main listed 19,401 pytest nodes and hit the address-guard basename mismatch. The rename and the combined tree each collected the same 19,408 nodes cleanly. The only seven additions are fromtests/test_address_guard_oracle.py. Both trees also discovered 10,637 unittest cases with zero loader errors on 3.14.10.The focused finder test failed with
SourceFileLoaderon 3.14.7 with the rename alone and passed when #2905 was added. On 3.14.10 it passed in both variants. The combined standalone oracle and semantic suites passed 7/7 and 12/12. The suite-wide counts are discovery and collection counts. AI-assisted (Codex).