Skip to content

Add a runner-completeness meta-test and route the d3d12_xs_surface runner through its real defs - #3203

Merged
ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
jaybeebabageyus:ht-runnermeta
Nov 23, 2026
Merged

ItsNotRexed merged 1 commit into
ItsNotRexed:mainfrom
jaybeebabageyus:ht-runnermeta

Conversation

@jaybeebabageyus

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: self-sourced runner-completeness meta-test + the d3d12_xs_surface instance it flags

What and why

tests/test_ci_registration.py sorts tests/test_*.py into CI jobs: a stdlib-mode file (no PYTEST_FILE_MARKERS match, real __main__ guard) is run only by the check loop as python -I tests/<file>.py, and pytest never imports it. When such a runner forgets to call one of the file's top-level def test_* functions, those checks run nowhere while the run still prints ok and exits 0. This class has already shipped twice: tests/test_cfg_structure.py's dead test_depth() (PR #3122) and tests/test_feature_scan.py's swallowed assert (PR #3051).

This PR adds tests/test_runner_calls_all_tests.py (stdlib-mode) as the runner counterpart of test_ci_registration.py: it imports that file's classification straight from .github/workflows/ci.yml (so it cannot drift from the workflow) and fails for every stdlib-mode file whose __main__ block neither names each top-level def test_* nor dispatches the whole set through the globals() loop some runners use (tests/test_desc_cache.py style). Intentional non-calls live in a RUNNER_SKIPS map with cited reasons: test_cfg_structure.py's test_random_graphs() one-line wrapper (the runner already calls _check_random_graphs(); listing the wrapper would run the 18,000-graph sweep twice) and test_depth() pending PR #3122 (entry is drop-once-merged). A bite check inside the test proves it still fails when a call is dropped from a runner this PR does not touch.

The one live instance the check flags on upstream/main 1628210 is fixed in the same PR: tests/test_d3d12_xs_surface.py's runner inline-duplicated the bodies of test_standard_iids_match_sdk/test_scarab_cross_check and never called the defs, so the CI python -I run exercised a drifting copy. The runner now calls both defs and catches unittest.SkipTest, so the no-SDK/no-SCARAB run stays green and checked == 83 is asserted by the def the loop actually executes.

Tested

Windows 11, Python 3.11.9, CPU only, no game data; all runs python -I on upstream/main 1628210 in a worktree:

  • tests/test_runner_calls_all_tests.py: 3/3 OK, twice (225 stdlib-mode files scanned).
  • tests/test_d3d12_xs_surface.py: ok exit 0 — the SDK check now runs through the real def (asserted checked == 83), SCARAB prints skipped: SCARAB_REF is not set.
  • Neighbors unchanged and green: test_ci_registration, test_cfg_structure, test_desc_cache, test_lane_masks.
  • Bite checks in scratch copies (never committed): commenting out test_straight_line() in test_lane_masks.py's runner fails the meta-test naming the file and def (exit 1); sabotaging the fixed d3d12 def body (assert checked == 83 -> == 84) exits 1 with AssertionError at the def, while the identical sabotage on the pristine upstream file printed ok exit 0 because only the inline copy ran — the drift this PR removes.

AI-assisted: yes (agentic coding assistant); every command and result above was executed locally in a worktree.

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • N/A — no translator rule in this PR (test-only change).

@evilclanker9000

Copy link
Copy Markdown
Contributor

Independent Windows Python check of a643180 against parent 1628210. The three runner meta-tests passed. Tracing the D3D12 script showed that the parent entered neither optional test definition, while this head entered both and correctly skipped SCARAB with SCARAB_REF unset. No native build or GPU work ran.

One case still slips through the new completeness check. A synthetic runner that only assigns tests = [test_example] returns an empty missing-test list even though it never calls test_example. The same fixture with a bare pass correctly reports the test as missing. The name collection at tests/test_runner_calls_all_tests.py:67 accepts registration alone. Please either narrow the stated guarantee to detecting unreferenced tests or add a check that accepts references only where the runner invokes or dispatches them.

AI-assisted.

@WHOISJARDAS

Copy link
Copy Markdown
Contributor

This meta-test doesn't catch one related case yet: a test defined below the runner block. When a stdlib-mode file runs as a script, both unittest.main() and a globals() loop run before that test exists. uncalled_tests() only looks at top-level functions, and it treats a globals() dispatch as complete, so it passes these files.

On main 1628210 this hid two TestCase classes:

  • PixelTestRegistry in tests/test_shader_checks.py (2 tests);
  • CarveUntilAdatTest in tests/test_rpf9_carve.py (3 tests).

#3236 moves both above their guards.

One extra check would cover this: in stdlib-mode files, fail for any top-level def test* or unittest.TestCase subclass whose lineno is greater than the runner block's end_lineno. With #3236 merged, no file on main trips it.

AI-assisted (Claude Code).

@ray3242

ray3242 commented Nov 22, 2026

Copy link
Copy Markdown
Contributor

At 5f96a6fa, the new tests/test_runner_calls_all_tests.py fails on main's tests/test_feature_scan.py, whose runner works. dispatches_tests() (:49-61) only accepts a for loop over globals() inside the __main__ block. Main's runner (test_feature_scan.py:457-459) passes a list comprehension over globals() to run_tests(...) instead, so uncalled_tests() (:70-76) reports all nine tests as dead:

$ python3.12 -I -m pytest -q tests/test_runner_calls_all_tests.py
E   tests/test_feature_scan.py: test_feature_scan() is defined but its __main__ runner never calls it, ...
E   tests/test_feature_scan.py: test_short_signature() is defined but its __main__ runner never calls it, ...
    (... 9 in total)
1 failed

The merge with main gives the same result. python -I tests/test_feature_scan.py on main prints test_feature_scan: OK (0 failed checks, 0 failed tests) and reaches all nine tests, so these reports are false. CI's stdlib loop runs the new file, so it would go red. One fix is to treat a globals()/vars() comprehension passed to a call in the runner as a dispatch too. This is a different case from the below-the-runner one raised above.

AI-assisted (Devin); Linux, Python 3.12.16, no GPU or game files.

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.

5 participants