SEMANTIC-PACKAGE-TESTS: include package initializers in parallel runner #474
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!474
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/474/head"
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?
@bobcatchris on GitHub · 2026-11-24 05:59 UTC · original
bobcatchris:semantic-package-tests→main· +55 −7 · 2 files · 1 commits · merged 2026-11-24 06:58 UTCClaimed in the coordination issue as: SEMANTIC-PACKAGE-TESTS
What and why
The default parallel translator-test runner selected only files matching
test*.py, butunittest discoveralso imports every package below the suite root and runs TestCase classes defined in a package's__init__.py. A failing test inpkg/__init__.pytherefore made-j 1fail while-j 2returned green with one fewer test.test_modulesnow includes package initializers even when no filename matches the pattern,module_pathhandles their path when sorting by size, and an empty initializer with no tests is not reported as a failure. Two regressions cover a failing initializer and a pattern that matches no test filenames.No game files, GPU, dependencies, keys or decryption are involved.
Tested
python -I tests/test_run_semantic_tests.py— 12 tests OK-j 1and-j 2now both fail on a failing package initializer (previously-j 2returned 0)python -I scripts/run_semantic_tests.py tests/semantic— 465 files, 6104 tests; onlytest_image_cube_store_glcfailed in this environment, also fails on unpatchedmainpython -I tests/test_ci_registration.py— 15 tests OKpython -m compileall -q scripts tests— OKgit diff --check— cleanGPUs tested: n/a (CPU-only runner and tests)
AI-assisted: yes
Checklist
mainand merges cleanly.@Dezmonius on GitHub · 2026-11-24 06:06 UTC · original
Independent Windows check at
27b3223(CPython 3.14.7). The 12 runner tests pass. I found two serial/parallel discrepancies with synthetic packages.The initializer executes twice in its own parallel worker.
python -m unittest pkg.__init__first importspkg, then executes the same file aspkg.__init__. For example, createpkg/helper.pycontainingregistrations = []and use thispkg/__init__.py:Run
python -I scripts/run_semantic_tests.py <fixture-root> -j 1and repeat with-j 2. Serial passes once. Parallel fails with['pkg', 'pkg.__init__']. Invokingpython -m unittest pkgfrom the fixture root passed and ran the initializer once. Could the initializer job invoke the package name, while retaining the initializer path for size sorting?An empty package alone gives a false green. With just an empty
pkg/__init__.py, serial exits 5, and parallel exits 0 with1 files, 0 tests, 0 files failed. Please preserve a nonzero exit for a whole run with zero tests while allowing empty initializer jobs alongside real tests.CPU-only synthetic fixtures. AI-assisted (Codex).
@csmith105 on GitHub · 2026-11-24 06:13 UTC · original · reviewed
Reviewed
27b3223edd6d7531fef3c3faaeebd34980ebb913on Windows/Python 3.12.14. I reproduced two package-discovery problems worth fixing before merging:pkg.__init__executes the initializer twice in one process: Python initializespkg, then imports the same file aspkg.__init__. Withcounter.pycontainingvisits = 0, this initializer passes with-j 1but fails with-j 2(2 != 1):load_testswithpattern=None, while child modules are still scheduled independently. This can still produce a false green. With a passingpkg/case_child.pyand this initializer,-p 'case_*.py' -j 1fails (one failing test), but-p 'case_*.py' -j 2succeeds (only the passing child runs):I also confirmed that a nested hook which suppresses discovery still has its excluded child run in parallel, and an empty-package-only suite returns 0 in parallel versus 5 in serial on this Python version.
A possible narrow approach is one discovery subprocess per top-level package subtree:
python -m unittest discover -s <suite>/pkg -t <suite> -p <pattern>, keeping root-level module jobs as they are and not separately scheduling package descendants. Small synthetic checks preserved initializer identity, nested hooks, the requested pattern and recursion suppression with that approach. Empty package jobs still need an overall no-tests check.AI-assisted review with OpenAI Codex; all behavior above was executed against the stated head, with no game files or GPU.
@milk4sale on GitHub · 2026-11-24 06:28 UTC · original
Two more package cases at
27b3223(Linux, CPython 3.14.10) where-j 2differs from-j 1, besides the ones above. In both, discover stops at the package (_find_test_pathreturns the import error or the skip and does not enter it), but the parallel runner still schedules its modules on their own:pkg/__init__.pyfails to import (import no_such_module_anywhere), with two passing modulespkg/test_one.pyandpkg/test_two.py:-j 1reports one import error (1 test).-j 2reports it three times, forpkg.__init__,pkg.test_oneandpkg.test_two(3 files, 3 tests, 3 files failed).pkg/__init__.pyraisesunittest.SkipTest('skip-pkg'), with a failingpkg/test_child.py:-j 1exits 0 withOK (skipped=1).-j 2exits 1: both jobs stop with an uncaughtunittest.case.SkipTest(2 files, 0 tests, 2 files failed).Running a package that discover does not enter as
python -m unittest discover -s <suite>/pkg -t <suite> -p <pattern>, as csmith105 suggests, gives the serial result in both cases. I checked that with synthetic-j 1/-j 2suites comparing exit code, test count and the-vtest ids.CPU-only synthetic fixtures, no game files. AI-assisted (Claude Code).
@Dezmonius on GitHub · 2026-11-24 06:51 UTC · original
Windows recheck at
b45d7c2with CPython 3.14.7 after the rebase onto the timeout change: all 17 runner tests pass, and both original fixtures still reproduce the serial/parallel discrepancies with--timeout 5.One interaction to account for if adopting the package-discovery subprocess proposed above:
--timeouton main currently applies per module with-j 2. I made a package with two test modules, each containing a single test that sleeps for 2.5 seconds. The current runner passes both under-j 2 --timeout 4. A singlepython -m unittest discover -s <suite>/pkg -t <suite> -p test*.pysubprocess times out at 4 seconds and passes both in 5 seconds when given a longer budget. Applying the same limit to a package discovery job therefore changes the meaning of that flag for packages. If the package-job approach is used, please make that scope explicit in the help and cover it with a regression test.Synthetic tests only. AI-assisted (Codex).
@QemmHD on GitHub · 2026-11-24 06:58 UTC · original
Merging. Why merged: parallel semantic runs now include package init modules, the same as discover.
Why it's good: security-reviewed; tested on Windows 11 merged onto main
c023a36: runner tests 15 -> 17 OK (7 failures on main without the fix); the real suite still selects the same 465 files and 6105 tests.AI-assisted (Claude Code, Claude Opus 5.5).