semantic_mutants: reject zero-test baselines (MUTANTS-ZERO-TEST-BASELINE) #987
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/987"
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?
Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-24T16:29:48Z.
Claimed in the coordination issue as: MUTANTS-ZERO-TEST-BASELINE — https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7137474008
What and why
When
setUpClassskips the only test class before any test starts,unittestreportsRan 0 testsand exits successfully.semantic_mutants.pythen runs the mutations against that empty baseline and reports them all as survivors. Recognize the zero-test summary as a baseline error and stop before running mutants. A synthetic CLI regression checks the exit code, diagnostic and absence of mutant results.Tested
After a rebase on
main6293c1c4(e8fa6b12, same patch asf2346123), on Windows 11, Python 3.12.4:tests/test_semantic_mutants.py21 OK;test_tool_stdout_encoding.py,test_docs_cli_flags.pyandtest_text_write_line_endings.pyOK;git diff --checkand the no-game-data check clean.mainatcf4c00cb, the synthetic regression returned 1 and reported three survivors. It now returns 2 withno tests ran.python -I -B tests/test_semantic_mutants.py: 21 passed.python -I -B tests/test_run_semantic_tests.py: 19 passed. The nested failing fixture is intentional.1f76d4a7in a temporary worktree: clean application, 22 mutation-tool tests and 20 semantic-runner tests passed.git diff --checkandpython -I -B scripts/check_no_game_data.py tools/semantic_mutants.py tests/test_semantic_mutants.py: passed.GPUs tested: n/a (CPU-only test tooling)
AI-assisted: yes (Codex).
Checklist
mainwhen branched; two-file diff checked againstmainbefore publication.Imported from ubiquitarianism/leonida. Originally posted by morodirule on 2026-11-24T16:33:40Z.
Independent Linux check (Python 3.14.10, stdlib only, no game/GPU): full tests/test_semantic_mutants.py passes 21/21 on head f23461231. The new test_class_skipped_before_any_test_is_a_baseline_error exercises the fix — with the unmodified run_test it fails exactly as reported (exit 1, all 3 mutants SURVIVED) instead of exit 2 with "no tests ran". This also confirms my earlier finding reproduction on #14. Not claiming; review evidence.
Imported from ubiquitarianism/leonida. Originally posted by fin-github on 2026-11-24T18:00:51Z.
Review: COMMENTED
python -I tests/test_semantic_mutants.pyon the PR: 21 tests OK (100 s).test_class_skipped_before_any_test_is_a_baseline_erroragainstmain's tool:AssertionError: 1 != 2, so it catches the bug.The regex matches the
OK/OK (skipped=N)summary on 3.14. Python 3.12+ normally exits 5 withNO TESTS RANfor zero tests, and the existingreturncode == 5branch covers that, so the two together handle bothforms. Looks good to me.
Tested on Windows 11 Pro 26200, CPython 3.14.4, MSVC from VS 18 Community, applied on main
32950551e. No GPU or game files used. AI-assisted (Claude Code).Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-24T21:22:26Z.
Rebased on
main6293c1c4:f2346123->e8fa6b12, same patch (git range-diff). The previous base failedtests/test_tool_stdout_encoding.py, which #948 fixed onmain, and the earlier CI run never started (action_required).tests/test_semantic_mutants.py21 OK;test_tool_stdout_encoding.py,test_docs_cli_flags.pyandtest_text_write_line_endings.pyOK;git diff --checkand the no-game-data check clean.f2346123.No code change in this rebase. CI on the new head is still queued.
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by tiguan26 on 2026-11-25T03:57:05Z.
Review: APPROVED
Approving. Merged into current main with no conflicts; the PR's tests pass (Linux, Python 3.13). Exit 0 with "Ran 0 tests ... OK" (a class or module fixture that skipped everything) is now treated like exit 5, so a mutant run cannot pass against a baseline that tested nothing.
AI-assisted (Claude).
Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-27T19:42:30Z.
Merge test and review, taken from the pool PRs MoonEyes had not checked yet. Main
ec91d695cmerged without conflict; the PR's test files run with the pins oftests/requirements.txton Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5).test_class_skipped_before_any_test_is_a_baseline_errorfails. The fix is shown.Ran 0 tests ... OK (skipped=1), which the new pattern catches.Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:25:47Z.
#987 | head
e8fa6b1258(merged cleanly onto origin/main5825b02ff8) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yesIndependent Verification (Windows 11)
tools/semantic_mutants.py(rejectingp.returncode == 0whenp.stderrmatches^Ran 0 tests in .+\n\nOK(?: \(skipped=\d+\))?$) andtests/test_semantic_mutants.py.python -I scripts/check_no_game_data.py tools/semantic_mutants.py tests/test_semantic_mutants.pypassed (rc=0).origin/main5825b02ff8): Invokingsemantic_mutants.run_test(...)on aunittest.TestCasewhosesetUpClassraisedunittest.SkipTest("no fixture")(Ran 0 tests in 0.000s\n\nOK (skipped=1),rc=0) returned(True, 'OK (skipped=1)'), allowing zero-test baselines to pass and falsely classify mutants as survived.#987 + origin/main):semantic_mutants.run_test(...)on the skipped-class probe returned(False, 'no tests ran').python -I tests/test_semantic_mutants.py->24/24passed (0skipped,OK,136.586s).Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-29T14:19:12Z.
Merged at head
e8fa6b1. Tested by others on this head: zmasi (Windows 11, Python 3.12) independent run, TheGeogeotests/test_semantic_mutants.py21 OK after the rebase. No GPU involved. AI-assisted: yes.