test(b-gate): two arms the mutation run demanded -- dead code around a door call
M1 (`if False:` counted as live) and M2 (code after `return` counted as live) both SURVIVED the whole suite. The pruning was real and nothing reached it: every dishonest form the arms already carried fell on the data-dependence rule first, so removing the pruning changed no verdict. The escape the pruning actually closes needs a probe that is GREEN in pytest: run a real process that is NOT the door, bind the name the assert reads, and put the door call in dead code under the same name. The taint then arrives from a line that can never run, and the probe "proves" a step it never touched. Both forms are planted here, each with the honest rc-0 control beside it. [mutation-ok] -- no guard is switched off. The `if False:` in this diff is INSIDE a Python string that the arm writes to a tmp_path file; the gate only PARSES that file, never runs it, and the arm asserts the form gives 0 of 1. The commit is the arm that makes dead-code pruning fall when it is removed. Found by mutating, not by reading. A rule no mutant can kill is a rule the suite has not measured. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
a3f9df5251
commit
6ca4c7eb9f
1 changed files with 45 additions and 0 deletions
|
|
@ -1906,3 +1906,48 @@ def test_a_subcommand_door_is_only_driven_when_the_command_stands_in_argv(
|
|||
row = gate.score_toolbox(steg, src, _fake_run_path(), _FAKE_PASSED, tmp_path)
|
||||
assert (row.k, row.n) == (0, 1), row.exceptions
|
||||
assert any("underkommandoen" in x for x in row.exceptions), row.exceptions
|
||||
|
||||
|
||||
#: To former MUTANTKJØRINGEN 20.09 fant, ikke dommeren: en probe som er GRØNN i pytest, kjører en
|
||||
#: ekte prosess som ikke er døren, og binder det samme navnet asserten leser i DØD kode. Uten
|
||||
#: beskjæringen av død kode teller dørkallet, og proben «beviser» et steg den aldri rørte. Begge
|
||||
#: mutantene (`if False:` regnes som levende · kode etter `return` regnes som levende) OVERLEVDE
|
||||
#: hele suiten før disse to armene fantes — regelen var ekte, men ingen arm nådde den.
|
||||
_DOED_KODE_FORMER: tuple[tuple[str, str], ...] = (
|
||||
(
|
||||
"doer-kallet-i-doed-gren-samme-navn",
|
||||
"import subprocess\nimport sys\n\n\n"
|
||||
"def <navn>(tmp_path):\n"
|
||||
' proc = subprocess.run([sys.executable, "-c", "pass"], capture_output=True)\n'
|
||||
" if False:\n"
|
||||
' proc = subprocess.run([sys.executable, "-m", "fakesrc.driver", "--steg", "gjoer_noe"])\n'
|
||||
" assert proc.returncode == 0\n",
|
||||
),
|
||||
(
|
||||
"doer-kallet-etter-return-samme-navn",
|
||||
"import subprocess\nimport sys\n\n\n"
|
||||
"def <navn>(tmp_path):\n"
|
||||
' proc = subprocess.run([sys.executable, "-c", "pass"], capture_output=True)\n'
|
||||
" assert proc.returncode == 0\n"
|
||||
" return\n"
|
||||
' proc = subprocess.run([sys.executable, "-m", "fakesrc.driver", "--steg", "gjoer_noe"])\n',
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(("form", "body"), _DOED_KODE_FORMER, ids=[n for n, _ in _DOED_KODE_FORMER])
|
||||
def test_a_door_call_that_can_never_run_is_not_an_execution(
|
||||
tmp_path: Path, form: str, body: str
|
||||
) -> None:
|
||||
"""Den ærlige proben teller (rc-0-kontroll), den døde formen ikke — og grunnen skal være at
|
||||
døren ikke RØRES, ikke at asserten mangler. Formen er realistisk med vilje: den er grønn i
|
||||
pytest, for den lever på en ekte prosess som bare ikke er døren."""
|
||||
src = _fake_src(tmp_path, chat_client=False)
|
||||
_write_probe(tmp_path)
|
||||
kontroll = gate.score_toolbox(_one_step(), src, _fake_run_path(), _FAKE_PASSED, tmp_path)
|
||||
assert (kontroll.k, kontroll.n) == (1, 1), kontroll.exceptions
|
||||
|
||||
_write_raw_probe(tmp_path, body)
|
||||
row = gate.score_toolbox(_one_step(), src, _fake_run_path(), _FAKE_PASSED, tmp_path)
|
||||
assert (row.k, row.n) == (0, 1), (form, row.exceptions)
|
||||
assert any("rører ikke døren" in x for x in row.exceptions), (form, row.exceptions)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue