run_semantic_tests: a package initializer runs once, and a run with no tests fails #557
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!557
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/557/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?
@ddddddddwp on GitHub · 2026-11-24 08:02 UTC · original
ddddddddwp:fix/semantic-parallel-initializer→main· +38 −3 · 2 files · 1 commits · merged 2026-11-24 08:54 UTCFinding: the 2026-11-24 07:17 comment in #14 (Dezmonius), claimed there.
What
Two serial/parallel differences in
scripts/run_semantic_tests.py:A package initializer ran twice in its
-j 2worker.test_modules()listspkg.__init__, andpython -m unittest pkg.__init__importspkgand then executes the same file again aspkg.__init__. Aregistration in the initializer therefore happened twice (
['pkg', 'pkg.__init__']) while-j 1(discover)imports it once.
run_module()now hands unittest the package name (pkg);module_path()still resolves theinitializer's path, so the largest-file-first order is unchanged and the failure still names
pkg.__init__.A run with no tests was green in parallel. With only an empty
pkg/__init__.py,-j 1exits 5 but-j 2printed
1 files, 0 tests, 0 files failedand exited 0. A parallel run where every job ran no tests now printsno tests ran in <dir>and exits 1. An empty initializer beside real tests is still accepted (the existingexit 5/NO TESTS RANmapping), because the run's total is above zero.Tests
tests/test_run_semantic_tests.py, two new cases:test_package_initializer_runs_once_in_parallel: apkg/__init__.pythat appends__name__and asserts the listis
['pkg'], in-j 1and-j 2.test_empty_package_alone_is_not_a_false_green: only an emptypkg/__init__.py, both modes must exit nonzero andthe parallel output names the reason.
Both fail against the previous script (
jobs=2subtest) and pass now:Manual fixture from the finding, with the new script:
-j 2gives1 files, 1 tests, 0 files failed(exit 0), andthe empty package gives
no tests ran in ...(exit 1, where the old script exited 0).macOS arm64, CPython 3.14.10, standard library only. No game files, no GPU, nothing online.
AI-assisted.
@Dezmonius on GitHub · 2026-11-24 08:17 UTC · original
Thanks for carrying over the finding. Independent Windows check at
66dac0d(CPython 3.14.7): all 19 runner tests pass. The original two fixtures confirm the fixes at-j 2 --timeout 5: the initializer runs once, and the empty suite exits 1. An empty initializer alongside a real test still passes. A hanging initializer at--timeout 2reports the timeout and the independent healthy module still runs.One new exit-code regression:
total == 0relies on the firstRan … tests inline from combined subprocess output. A test module can emit that line before unittest emits its own summary. Put this in an otherwise empty suite astest_pass.py:On Windows with both CPython 3.12.10 and 3.14.7,
-j 1 --timeout 5exits 0, and-j 2 --timeout 5on this PR prints unittest'sRan 1 testandOK, then exits 1 withno tests ran. On main1c93c86, the same parallel command exits 0 despite the inaccurate summary count. Could the new empty-run decision use the subprocess's explicit no-tests outcome (exit 5 for the empty fixture on both tested versions) separately from the count scraped for display?CPU-only synthetic fixtures. AI-assisted (Codex).
@QemmHD on GitHub · 2026-11-24 08:54 UTC · original
Merging. Why merged: a package initializer no longer runs twice, and a semantic run in which no test ran no longer counts as a pass.
Why it's good: on main
1c93c86: runner tests 17 -> 19; the full semantic run with the new runner still selects 465 files / 6108 tests; repo-consistency set 563 -> 565 (its own new tests), 0 failures.AI-assisted (Claude Code, Claude Opus 5.5).