[PR #557] [MERGED] run_semantic_tests: a package initializer runs once, and a run with no tests fails #603

Closed
opened 2026-11-26 20:18:26 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/557
Author: @ddddddddwp
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/24/2026
Merged by: @QemmHD

Base: main ← Head: fix/semantic-parallel-initializer


📝 Commits (1)

  • 66dac0d run_semantic_tests: a package initializer runs once, and a run with no tests fails

📊 Changes

2 files changed (+38 additions, -3 deletions)

View changed files

📝 scripts/run_semantic_tests.py (+12 -3)
📝 tests/test_run_semantic_tests.py (+26 -0)

📄 Description

Finding: the 2026-11-24 07:17 comment in #14 (Dezmonius), claimed there.

What

Two serial/parallel differences in scripts/run_semantic_tests.py:

  1. A package initializer ran twice in its -j 2 worker. test_modules() lists pkg.__init__, and
    python -m unittest pkg.__init__ imports pkg and then executes the same file again as pkg.__init__. A
    registration 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 the
    initializer's path, so the largest-file-first order is unchanged and the failure still names pkg.__init__.

  2. A run with no tests was green in parallel. With only an empty pkg/__init__.py, -j 1 exits 5 but -j 2
    printed 1 files, 0 tests, 0 files failed and exited 0. A parallel run where every job ran no tests now prints
    no tests ran in <dir> and exits 1. An empty initializer beside real tests is still accepted (the existing
    exit 5/NO TESTS RAN mapping), 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: a pkg/__init__.py that appends __name__ and asserts the list
    is ['pkg'], in -j 1 and -j 2.
  • test_empty_package_alone_is_not_a_false_green: only an empty pkg/__init__.py, both modes must exit nonzero and
    the parallel output names the reason.

Both fail against the previous script (jobs=2 subtest) and pass now:

$ python -I tests/test_run_semantic_tests.py
Ran 19 tests in 3.5s
OK

Manual fixture from the finding, with the new script: -j 2 gives 1 files, 1 tests, 0 files failed (exit 0), and
the 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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/557 **Author:** [@ddddddddwp](https://github.com/ddddddddwp) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/24/2026 **Merged by:** [@QemmHD](https://github.com/QemmHD) **Base:** `main` ← **Head:** `fix/semantic-parallel-initializer` --- ### 📝 Commits (1) - [`66dac0d`](https://github.com/ubiquitarianism/leonida/commit/66dac0d93870fe9a2d4d808b1d1c56a777468d5b) run_semantic_tests: a package initializer runs once, and a run with no tests fails ### 📊 Changes **2 files changed** (+38 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `scripts/run_semantic_tests.py` (+12 -3) 📝 `tests/test_run_semantic_tests.py` (+26 -0) </details> ### 📄 Description Finding: the 2026-11-24 07:17 comment in #14 (Dezmonius), claimed there. ## What Two serial/parallel differences in `scripts/run_semantic_tests.py`: 1. **A package initializer ran twice in its `-j 2` worker.** `test_modules()` lists `pkg.__init__`, and `python -m unittest pkg.__init__` imports `pkg` and then executes the same file again as `pkg.__init__`. A registration 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 the initializer's path, so the largest-file-first order is unchanged and the failure still names `pkg.__init__`. 2. **A run with no tests was green in parallel.** With only an empty `pkg/__init__.py`, `-j 1` exits 5 but `-j 2` printed `1 files, 0 tests, 0 files failed` and exited 0. A parallel run where every job ran no tests now prints `no tests ran in <dir>` and exits 1. An empty initializer beside real tests is still accepted (the existing `exit 5`/`NO TESTS RAN` mapping), 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`: a `pkg/__init__.py` that appends `__name__` and asserts the list is `['pkg']`, in `-j 1` and `-j 2`. - `test_empty_package_alone_is_not_a_false_green`: only an empty `pkg/__init__.py`, both modes must exit nonzero and the parallel output names the reason. Both fail against the previous script (`jobs=2` subtest) and pass now: ``` $ python -I tests/test_run_semantic_tests.py Ran 19 tests in 3.5s OK ``` Manual fixture from the finding, with the new script: `-j 2` gives `1 files, 1 tests, 0 files failed` (exit 0), and the 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:26 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#603
No description provided.