semantic_mutants: reject zero-test baselines (MUTANTS-ZERO-TEST-BASELINE) #987

Merged
TheGeogeo merged 1 commit from upstream-pr/987 into main 2026-11-29 14:09:42 +00:00
TheGeogeo commented 2026-11-24 16:29:48 +00:00 (Migrated from github.com)

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 setUpClass skips the only test class before any test starts, unittest reports Ran 0 tests and exits successfully. semantic_mutants.py then 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 main 6293c1c4 (e8fa6b12, same patch as f2346123), on Windows 11, Python 3.12.4: tests/test_semantic_mutants.py 21 OK; test_tool_stdout_encoding.py, test_docs_cli_flags.py and test_text_write_line_endings.py OK; git diff --check and the no-game-data check clean.

  • Windows, Python 3.12.4. On main at cf4c00cb, the synthetic regression returned 1 and reported three survivors. It now returns 2 with no 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.
  • Combined with #863 at 1f76d4a7 in a temporary worktree: clean application, 22 mutation-tool tests and 20 semantic-runner tests passed.
  • git diff --check and python -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

  • Based on current main when branched; two-file diff checked against main before publication.
  • One topic.
  • No game data, keys or decryption.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5476197026 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/987). Originally posted by [TheGeogeo](https://github.com/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 `setUpClass` skips the only test class before any test starts, `unittest` reports `Ran 0 tests` and exits successfully. `semantic_mutants.py` then 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 `main` `6293c1c4` (`e8fa6b12`, same patch as `f2346123`), on Windows 11, Python 3.12.4: `tests/test_semantic_mutants.py` 21 OK; `test_tool_stdout_encoding.py`, `test_docs_cli_flags.py` and `test_text_write_line_endings.py` OK; `git diff --check` and the no-game-data check clean. - Windows, Python 3.12.4. On `main` at `cf4c00cb`, the synthetic regression returned 1 and reported three survivors. It now returns 2 with `no 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. - Combined with #863 at `1f76d4a7` in a temporary worktree: clean application, 22 mutation-tool tests and 20 semantic-runner tests passed. - `git diff --check` and `python -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 - [x] Based on current `main` when branched; two-file diff checked against `main` before publication. - [x] One topic. - [x] No game data, keys or decryption.
morodirule commented 2026-11-24 16:33:40 +00:00 (Migrated from github.com)

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.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7137857520 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/987#issuecomment-7137857520). Originally posted by [morodirule](https://github.com/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.
fin-github commented 2026-11-24 18:00:51 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fin-github on 2026-11-24T18:00:51Z.

Review: COMMENTED


  • python -I tests/test_semantic_mutants.py on the PR: 21 tests OK (100 s).
  • The new test_class_skipped_before_any_test_is_a_baseline_error against main'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 with
NO TESTS RAN for zero tests, and the existing returncode == 5 branch covers that, so the two together handle both
forms. 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).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6044650490 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/987#pullrequestreview-6044650490). Originally posted by [fin-github](https://github.com/fin-github) on 2026-11-24T18:00:51Z. **Review:** COMMENTED --- - `python -I tests/test_semantic_mutants.py` on the PR: 21 tests OK (100 s). - The new `test_class_skipped_before_any_test_is_a_baseline_error` against `main`'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 with `NO TESTS RAN` for zero tests, and the existing `returncode == 5` branch covers that, so the two together handle both forms. 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).
TheGeogeo commented 2026-11-24 21:22:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-24T21:22:26Z.


Rebased on main 6293c1c4: f2346123 -> e8fa6b12, same patch (git range-diff). The previous base failed tests/test_tool_stdout_encoding.py, which #948 fixed on main, and the earlier CI run never started (action_required).

  • Windows 11, Python 3.12.4, after the rebase: tests/test_semantic_mutants.py 21 OK; test_tool_stdout_encoding.py, test_docs_cli_flags.py and test_text_write_line_endings.py OK; git diff --check and the no-game-data check clean.
  • The earlier feedback here was on f2346123.

No code change in this rebase. CI on the new head is still queued.

AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144844272 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/987#issuecomment-7144844272). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-24T21:22:26Z. --- Rebased on `main` `6293c1c4`: `f2346123` -> `e8fa6b12`, same patch (`git range-diff`). The previous base failed `tests/test_tool_stdout_encoding.py`, which #948 fixed on `main`, and the earlier CI run never started (action_required). - Windows 11, Python 3.12.4, after the rebase: `tests/test_semantic_mutants.py` 21 OK; `test_tool_stdout_encoding.py`, `test_docs_cli_flags.py` and `test_text_write_line_endings.py` OK; `git diff --check` and the no-game-data check clean. - The earlier feedback here was on `f2346123`. No code change in this rebase. CI on the new head is still queued. AI-assisted: yes (Claude Code).
tiguan26 commented 2026-11-25 03:57:05 +00:00 (Migrated from github.com)

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).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6051647189 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/987#pullrequestreview-6051647189). Originally posted by [tiguan26](https://github.com/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).
OreoFR commented 2026-11-27 19:42:30 +00:00 (Migrated from github.com)

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 ec91d695c merged without conflict; the PR's test files run with the pins of tests/requirements.txt on Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5).

  • Tests: with the PR 24 passed; against main: test_class_skipped_before_any_test_is_a_baseline_error fails. The fix is shown.
  • A class whose setup skips gives exit 0 and Ran 0 tests ... OK (skipped=1), which the new pattern catches.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7226792461 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/987#issuecomment-7226792461). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-27T19:42:30Z. --- Merge test and review, taken from the pool PRs MoonEyes had not checked yet. Main ec91d695c merged without conflict; the PR's test files run with the pins of `tests/requirements.txt` on Windows 11, Python 3.12 (venv). AI-assisted (Claude Code, Claude Opus 5.5). - **Tests:** with the PR 24 passed; against main: `test_class_skipped_before_any_test_is_a_baseline_error` fails. The fix is shown. - A class whose setup skips gives exit 0 and `Ran 0 tests ... OK (skipped=1)`, which the new pattern catches.
zmasi commented 2026-11-29 01:25:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-29T01:25:47Z.


#987 | head e8fa6b1258 (merged cleanly onto origin/main 5825b02ff8) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes

Independent Verification (Windows 11)

  • Diff & safety audit: Inspected 100% of the diff across tools/semantic_mutants.py (rejecting p.returncode == 0 when p.stderr matches ^Ran 0 tests in .+\n\nOK(?: \(skipped=\d+\))?$) and tests/test_semantic_mutants.py. python -I scripts/check_no_game_data.py tools/semantic_mutants.py tests/test_semantic_mutants.py passed (rc=0).
  • Red -> Green on Windows 11:
    • Red (origin/main 5825b02ff8): Invoking semantic_mutants.run_test(...) on a unittest.TestCase whose setUpClass raised unittest.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.
    • Green (#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/24 passed (0 skipped, OK, 136.586s).
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7248776417 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/987#issuecomment-7248776417). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-29T01:25:47Z. --- #987 | head e8fa6b1258ec10fdcf0d44514f5b4511abc55087 (merged cleanly onto origin/main 5825b02ff8) | Windows 11 (10.0.26200.9974), Python 3.12.10 | AI-assisted: yes ### Independent Verification (Windows 11) - **Diff & safety audit**: Inspected 100% of the diff across `tools/semantic_mutants.py` (rejecting `p.returncode == 0` when `p.stderr` matches `^Ran 0 tests in .+\n\nOK(?: \(skipped=\d+\))?$`) and `tests/test_semantic_mutants.py`. `python -I scripts/check_no_game_data.py tools/semantic_mutants.py tests/test_semantic_mutants.py` passed (`rc=0`). - **Red -> Green on Windows 11**: - **Red (`origin/main` `5825b02ff8`)**: Invoking `semantic_mutants.run_test(...)` on a `unittest.TestCase` whose `setUpClass` raised `unittest.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. - **Green (`#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/24` passed (`0` skipped, `OK`, `136.586s`).
MoonEyes commented 2026-11-29 14:19:12 +00:00 (Migrated from github.com)

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, TheGeogeo tests/test_semantic_mutants.py 21 OK after the rebase. No GPU involved. AI-assisted: yes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7257210507 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/987#issuecomment-7257210507). Originally posted by [MoonEyes](https://github.com/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, TheGeogeo `tests/test_semantic_mutants.py` 21 OK after the rebase. No GPU involved. AI-assisted: yes.
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!987
No description provided.