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

Merged
KelboLive merged 1 commit from upstream-pr/2903 into main 2026-12-02 01:20:26 +00:00
KelboLive commented 2026-12-01 16:55:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T16:55:19Z.


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

  • Test-only rename; no game data, no behaviour change.
  • git merge-tree against current main is clean.
  • Independent of #2869; the two can land in either order.

AI-assisted: yes

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5590370985 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2903). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T16:55:19Z. --- ### 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 - Test-only rename; no game data, no behaviour change. - `git merge-tree` against current `main` is clean. - Independent of #2869; the two can land in either order. AI-assisted: yes
merzleckeier commented 2026-12-01 18:04:12 +00:00 (Migrated from github.com)

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 -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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320354643 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2903#issuecomment-7320354643). Originally posted by [merzleckeier](https://github.com/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 -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 commented 2026-12-01 18:05:49 +00:00 (Migrated from github.com)

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 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320396565 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2903#issuecomment-7320396565). Originally posted by [Kal0s-design](https://github.com/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 `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 commented 2026-12-01 18:15:47 +00:00 (Migrated from github.com)

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:

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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320658513 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2903#issuecomment-7320658513). Originally posted by [KelboLive](https://github.com/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: ``` 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 commented 2026-12-01 18:21:29 +00:00 (Migrated from github.com)

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/ 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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7320815462 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2903#issuecomment-7320815462). Originally posted by [KelboLive](https://github.com/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/` 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.
merzleckeier commented 2026-12-01 19:26:33 +00:00 (Migrated from github.com)

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 4afb7131 on current main 93ffc482, 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 from tests/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 SourceFileLoader on 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7322824131 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2903#issuecomment-7322824131). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T19:26:33Z. --- Discovery recheck of the rebased rename and import-order combination at `4afb7131` on current main `93ffc482`, 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 from `tests/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 `SourceFileLoader` on 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).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2903
No description provided.