Fail semantic runs that exit without a trustworthy result (SEMANTIC-RUNNER-COMPLETION) #1437

Open
github-bot wants to merge 2 commits from github-bot/gh-1437 into main AGit
Owner

@⁠titoreinaldo on GitHub · 2026-11-25 00:14 UTC · original
titoreinaldo:fix/semantic-runner-completion → main · +73 −25 · 2 files · 2 commits · open

Claimed in the coordination issue as: SEMANTIC-RUNNER-COMPLETION (#14 claim).

What and why

An incomplete semantic run can report success. A synthetic module calling os._exit(0) during import leaves no unittest result; the parallel runner counts zero for that worker and accepts its process status, and the serial runner simply forwards success. An exit handler can also overwrite the status after unittest has completed with a failure.

Use unittest’s completed result as well as the process exit status in both modes. Status 0 without a result, or after unittest reported a nonzero status, is an error. Empty package initializers are still ignored based on the recorded result, and timeouts retain their existing diagnostics. Discovery rules are unchanged.

Tested

  • Both synthetic regressions fail against main 1154976d with either -j 1 or -j 2: four false-green cases before, all four detected after.
  • python -I tests/test_run_semantic_tests.py: 24 tests pass.
  • python -I scripts/run_semantic_tests.py tests/semantic -j 8: 476 files, 6,223 tests, zero failing files.
  • Compile, diff whitespace and no-game-data checks passed.

GPUs tested: none, Linux x86-64 / Python 3.12.14, CPU-only. No game files, keys, decryption, or online game services. AI-assisted: yes, OpenAI Codex.

**@⁠titoreinaldo** on GitHub · 2026-11-25 00:14 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1437) `titoreinaldo:fix/semantic-runner-completion` → `main` · +73 −25 · 2 files · 2 commits · open Claimed in the coordination issue as: SEMANTIC-RUNNER-COMPLETION ([#14 claim](https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14)). ### What and why An incomplete semantic run can report success. A synthetic module calling `os._exit(0)` during import leaves no unittest result; the parallel runner counts zero for that worker and accepts its process status, and the serial runner simply forwards success. An exit handler can also overwrite the status after unittest has completed with a failure. Use unittest’s completed result as well as the process exit status in both modes. Status 0 without a result, or after unittest reported a nonzero status, is an error. Empty package initializers are still ignored based on the recorded result, and timeouts retain their existing diagnostics. Discovery rules are unchanged. ### Tested - Both synthetic regressions fail against main `1154976d` with either `-j 1` or `-j 2`: four false-green cases before, all four detected after. - `python -I tests/test_run_semantic_tests.py`: 24 tests pass. - `python -I scripts/run_semantic_tests.py tests/semantic -j 8`: 476 files, 6,223 tests, zero failing files. - Compile, diff whitespace and no-game-data checks passed. GPUs tested: none, Linux x86-64 / Python 3.12.14, CPU-only. No game files, keys, decryption, or online game services. AI-assisted: yes, OpenAI Codex.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:51:26 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 15:27 UTC · original

Reviewed 84f8fee73: run_semantic_tests.py now takes the verdict from the child's {testsRun, exitCode} result file: a child that exits 0 without a result, or against unittest's own verdict, fails the run, and -j 1 shares the child program instead of a bare python -m unittest discover. Ran tests/test_run_semantic_tests.py on both trees: 24 tests OK on the PR, and on main exactly the two new tests fail; both bugs reproduce (an import-time os._exit(0) and an atexit-forced exit 0 after a failed test report "0 files failed" on main). Ran the runner on tests/semantic -p 'test_alu_add*.py' in both modes on both trees: 6 files, 69 tests, 0 failed, identical output. Probed a passing module with an atexit os._exit(0) (still passes; no false positive) and a mid-test SIGKILL (still fails). No findings. Note, follow-up material only: a module that deliberately writes LEONIDA_TEST_COUNT can still forge a green verdict everywhere except main's serial mode, which was immune by accident.

AI-assisted review.

Recommendation: Merge

**@⁠PierreEbele** on GitHub · 2026-11-25 15:27 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/1437#issuecomment-7166866309) Reviewed 84f8fee73: run_semantic_tests.py now takes the verdict from the child's `{testsRun, exitCode}` result file: a child that exits 0 without a result, or against unittest's own verdict, fails the run, and `-j 1` shares the child program instead of a bare `python -m unittest discover`. Ran tests/test_run_semantic_tests.py on both trees: 24 tests OK on the PR, and on main exactly the two new tests fail; both bugs reproduce (an import-time `os._exit(0)` and an atexit-forced exit 0 after a failed test report "0 files failed" on main). Ran the runner on `tests/semantic -p 'test_alu_add*.py'` in both modes on both trees: 6 files, 69 tests, 0 failed, identical output. Probed a passing module with an atexit `os._exit(0)` (still passes; no false positive) and a mid-test SIGKILL (still fails). No findings. Note, follow-up material only: a module that deliberately writes LEONIDA_TEST_COUNT can still forge a green verdict everywhere except main's serial mode, which was immune by accident. AI-assisted review. **Recommendation:** Merge
This pull request has changes conflicting with the target branch.
  • scripts/run_semantic_tests.py
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1437/head:github-bot/gh-1437'
git switch 'github-bot/gh-1437'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1437'
git switch 'github-bot/gh-1437'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1437'
git switch 'github-bot/gh-1437'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1437'
git switch 'main'
git merge --squash 'github-bot/gh-1437'
git switch 'main'
git merge --ff-only 'github-bot/gh-1437'
git switch 'main'
git merge 'github-bot/gh-1437'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.