Skip to content

tests: rename the address-guard unit test so discovery stops importing two test_address_guard modules - #2903

Open
KelboLive wants to merge 1 commit into
ProjectLeonida:mainfrom
KelboLive:tests/address-guard-basename
Open

KelboLive wants to merge 1 commit into
ProjectLeonida:mainfrom
KelboLive:tests/address-guard-basename

Conversation

@KelboLive

Copy link
Copy Markdown

What and why

python -m pytest tests/ and python -m unittest discover -s tests both fail on current main because two test modules share a basename:

tests/test_address_guard.py
tests/semantic/test_address_guard.py

Discovery imports one as test_address_guard and then refuses the other (import file mismatch for pytest; module incorrectly imported from … for unittest). On main 85ec1d33b:

pytest tests/ --collect-only -q   -> 1 error, exit 1
unittest discover -s tests        -> ImportError: 'test_address_guard' module incorrectly imported

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-end rdna2spirv.py --address-guard test (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 its AddressGuardOracleTest class, 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:

pytest tests/ --collect-only -q      -> 19375 tests collected, 0 errors
unittest discover -s tests           -> 10610 tests discovered, no ImportError
python -I tests/test_address_guard_oracle.py   -> Ran 7, OK
python -I tests/semantic/test_address_guard.py -> Ran 12, OK

python -m pytest tests/semantic/ is unchanged, and the rename works whether or not #2869's tests/semantic/__init__.py lands (that fixes pytest collection only; unittest discover still 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) and python -I scripts/check_no_game_data.py on the renamed file. The full semantic suite is 554 files / 6,743 tests, 0 failed.

Notes

AI-assisted: yes

@merzleckeier

Copy link
Copy Markdown
Contributor

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 -q found 19,388 tests and the test_address_guard import 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 3c4fc452 renames 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 scoped test_support_installs_the_finder_only_where_the_tokenizer_is_slow still 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).

@Kal0s-design

Copy link
Copy Markdown
Contributor

Verified on Windows 11, Python 3.13.12. pytest is not installed on this machine, so this covers the unittest half only.

Discovery only (unittest.TestLoader().discover("tests"), which imports every module without running the tests):

tree result
main d2a564b66 aborts: ImportError: 'test_address_guard' module incorrectly imported from ...\tests\semantic. Expected ...\tests
this PR 5d778207a completes: 10,637 test cases found

On 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 -v gives 7 tests, OK. Running it as -m unittest test_address_guard_oracle from inside tests/ with -I cannot find it, but that is -I dropping 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).

@KelboLive
KelboLive force-pushed the tests/address-guard-basename branch from 5d77820 to eb4bedc Compare December 1, 2026 18:15
@KelboLive

Copy link
Copy Markdown
Author

Rebased onto current main (7fbdf8511) and re-measured, since the tree moved ~50 commits since this was opened:

main 7fbdf8511:
  pytest tests/ --collect-only -q   -> 19395 collected, 1 error (tests/test_address_guard.py)
  unittest discover -s tests        -> ImportError: 'test_address_guard' module incorrectly imported
                                       from 'tests/semantic', expected 'tests'

this branch (eb4bedce6):
  pytest tests/ --collect-only -q   -> 19402 tests collected, 0 errors
  unittest discover -s tests        -> 10631 tests discovered
  python -I tests/test_address_guard_oracle.py   -> Ran 7, OK
  python -I tests/semantic/test_address_guard.py -> Ran 12, OK

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.

@KelboLive

Copy link
Copy Markdown
Author

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/ and python -m unittest discover -s tests both abort on main today because two modules are both named test_address_guard, and the collision takes down collection of the whole tests/ tree (including the d3d12/ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants