Skip to content

tests: the CI registration scan counts the tests a TestCase inherits from a class of its module (TEST-CI-REG-LOCAL-MIXIN) - #1365

Merged
aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
milk4sale:test/ci-registration-local-mixin
Nov 24, 2026
Merged

aslan2142 merged 1 commit into
ProjectLeonida:mainfrom
milk4sale:test/ci-registration-local-mixin

Conversation

@milk4sale

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: TEST-CI-REG-LOCAL-MIXIN (#14 (comment))

What and why

main is red on tests/test_ci_registration.py since 540d5111f, the merge of #930 at 22:12 UTC on 24 November; the test passes on that commit's parent, 4a50cafc7. The standard-library loop runs this file, so check, stdlib-tests-linux and macos-python fail on every pull request whose run starts on a main from then on.

test_every_selected_file_exposes_a_test_to_its_runner reports #930's tests/semantic/test_sub_co_same_operand.py as a file the semantic job collects nothing from. That is not so: python -m unittest discover -s tests/semantic -p test_sub_co_same_operand.py runs 6 tests there. Its three TestCase classes have no test method of their own. They take them from _SameOperandMixin, a plain class defined in the same file, one TestCase per wave size. defines_a_test looked at a TestCase's own body and at a base imported from another module, and not at a base defined in the module, so the fault is in the scan and #930's file stays as it is.

The scan now also counts:

  • the test* methods of the classes of the module that a TestCase derives from, directly or through other classes of the module;
  • a base imported from another module that is reached that way (class Middle(Imported), then class Example(Middle, unittest.TestCase)), as it already did for one the TestCase names itself.

unittest's loader lists a class's tests with dir(), so these are tests the runner runs.

Tested

  • python -I tests/test_ci_registration.py: 16 tests pass on this branch (main 89d7dfcf5 plus the commit). On main alone it fails at test_every_selected_file_exposes_a_test_to_its_runner; at 4a50cafc7 it passes and at 540d5111f it fails.
  • The new test, test_inherited_tests_count_where_unittest_discover_collects_them, does not carry my expectations alone: it writes eight small modules, runs unittest discover on them once and holds the scan to what the runner collected. Five have a test (a mixin above the TestCase, two classes up, beside a TestCase base without tests, an imported mixin named directly and through a local class) and three have none (a base without tests, a mixin no TestCase derives from, a mixin without a TestCase).
  • Control: with main's defines_a_test put back, that test fails in four of the five cases with a test (all but the directly named imported mixin, which main already handled), and the repository check fails as on main.
  • Over the whole repository, at 51a6074d2: both scans list the same 997 test files. Of the 473 files the semantic job selects, main's scan finds a test in 472 and this one in 473; test_sub_co_same_operand.py is the only file the two disagree on, and they agree on all 36 files of the pytest job. unittest's loader collects tests from all 473 semantic files (6191 tests, no import failure). So main's scan disagreed with the runner on that one file, and this one disagrees on none.
  • Every standalone test file under tests/ with python -I (491 files): all pass, where main has the one failure.
  • python -I scripts/check_no_game_data.py tests/test_ci_registration.py, python -m compileall and git diff --check.

Run with Python 3.14.10 on Linux. Not run locally: Python 3.12 (the version CI installs), Windows and macOS. The new test reads unittest's verbose output the way test_semantic_selection_matches_discovery_through_packages in the same file already does.

GPUs tested: n/a (one Python test file; no shader, fixture or runtime code)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (No translator change.)

🤖 Generated with Claude Code

…from a class of its module (TEST-CI-REG-LOCAL-MIXIN)

tests/test_ci_registration.py fails on main since 540d511 (the merge of ProjectLeonida#930) and passes on its parent:
test_every_selected_file_exposes_a_test_to_its_runner reports tests/semantic/test_sub_co_same_operand.py as a file
the semantic job collects nothing from. `python -m unittest discover -s tests/semantic -p
test_sub_co_same_operand.py` runs 6 tests there. Its three TestCase classes have no test method of their own: they
take them from a mixin class defined in the same file, one TestCase per wave size. defines_a_test looked at a
TestCase's own body and at a base imported from another module, not at a base defined in the module.

It now also counts the test* methods of the classes of the module a TestCase derives from, directly or through
other classes of the module, and an imported base reached that way. unittest's loader lists a class's tests with
dir(), so these are the tests it runs.

The new test writes eight small modules, runs unittest discover on them once and holds the scan to what the runner
collected: a mixin above the TestCase, two classes up, beside a TestCase base without tests, an imported mixin
named directly and through a local class (a test each), and a base without tests, a mixin no TestCase derives
from and a mixin without a TestCase (none). With main's defines_a_test put back, four of the five cases with a
test fail, and so does the repository check.

Over the repository at 51a6074: the scan lists the same 997 test files; of the 473 the semantic job selects,
main's scan found a test in 472 and this one in 473, and test_sub_co_same_operand.py is the only file the two
disagree on (none of the pytest job's 36). unittest's loader collects tests from all 473 (6191 tests, no import
failure), so main's scan disagreed with the runner on that one file and this one on none.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@milk4sale

milk4sale commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

CI for this commit on my fork, since the queue here is hours behind: https://github.com/milk4sale/leonida/actions/runs/45502632816 (a manual run of the CI workflow on the branch as it is, fd0a53907 on main 89d7dfcf5; Python 3.12).

Edited at 23:25 and 23:38 UTC: the first version of this comment named two failing files and left out tests/test_run_wine_tests.py; the second called its error an IndexError and miscounted the later runs.

AI-assisted.

@xel1uz xel1uz mentioned this pull request Nov 24, 2026
3 tasks done
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
… with ProjectLeonida#1012 merged

Takes the updated head of ProjectLeonida#1034's branch, which holds main 6558d53 (ProjectLeonida#1012, GPU-CMP-F64, is merged there). Git merged
it without conflicts (git merge-tree, exit 0), and the tree is the one a direct merge of main gives. GitHub had
reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782). Merging
ProjectLeonida#1034's head instead of main leaves this branch with one merge base with main when ProjectLeonida#1034 merges.

The merged tree was tested before the push: every standalone test file under tests/ passes except
tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
milk4sale added a commit to milk4sale/leonida that referenced this pull request Nov 24, 2026
…ProjectLeonida#1012 merged

Takes the updated head of ProjectLeonida#1034's branch, which holds main 6558d53 (ProjectLeonida#1012, GPU-CMP-F64, is merged there). Git merged
it without conflicts (git merge-tree, exit 0), and the tree is the one a direct merge of main gives. GitHub had
reported a conflict since ProjectLeonida#1012 merged, with the branch and main on two merge bases (68d1331 and 5040782). Merging
ProjectLeonida#1034's head instead of main leaves this branch with one merge base with main when ProjectLeonida#1034 merges.

The merged tree was tested before the push: every standalone test file under tests/ passes except
tests/test_ci_registration.py, which fails on main 6558d53 alone (ProjectLeonida#1365 fixes it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
aslan2142 pushed a commit that referenced this pull request Nov 24, 2026
Brings the branch up to date with main 6558d53, which now holds #1012 (GPU-CMP-F64), the pull request this one was
stacked on. Git merged it without conflicts (git merge-tree, exit 0). GitHub had reported a conflict since #1012
merged, with the branch and main on two merge bases (68d1331 and 5040782); main is an ancestor of this commit.

The merged tree was tested before the push: every standalone test file under tests/ passes except
tests/test_ci_registration.py, which fails on main 6558d53 alone (#1365 fixes it).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@aslan2142
aslan2142 merged commit 3a0af1f into ProjectLeonida:main Nov 24, 2026
2 checks passed
@aslan2142

Copy link
Copy Markdown
Collaborator

Merged. Thanks: this turns tests/test_ci_registration.py green on main again.

  • Why it was red: rdna2spirv: write out a carry-out subtract of a register from itself (AMD Windows driver crash) (SHADER-SUB-CO-SAME) #930 added tests/semantic/test_sub_co_same_operand.py, whose TestCase classes inherit their tests from a mixin in the same file, and the scan counted that file as having no test. I merged rdna2spirv: write out a carry-out subtract of a register from itself (AMD Windows driver crash) (SHADER-SUB-CO-SAME) #930 without running this file, so that one is on me; it made check, stdlib-tests-linux and macos-python fail on every pull request since.
  • Claim: valid. TEST-CI-REG-LOCAL-MIXIN was posted at 22:30 UTC, before this PR, and is unedited.
  • The fix is right: the scan now walks the base classes defined in the same file, with a visited list so a cycle cannot loop, and counts their test* methods. Over every tests/**/test_*.py, only tests/semantic/test_sub_co_same_operand.py changes its result, from no test to having one. The change can only add tests to a file's count, so no file is newly flagged.
  • tests/test_ci_registration.py: on main 15 tests with 1 failure; with this PR 16 tests, all passing. The new test fails 4 of its cases against main's version of the scan.
  • On main cdb003ea1 + fd0a53907: the semantic suite passes (475 files, 6,220 tests, 0 files failed); the 13 docs and writer tests pass; check_no_game_data.py is clean on the 1 changed files.
  • CI had not finished on this head.

The case of an inherited @property test_* is left to the follow-up #1385.

AI-assisted (Claude Code, Claude Fable 5.2 and Claude Opus 5.5).

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.

2 participants