Review main Ready for review

98101[TASK] Catch weak tests with local mutation testing

Matthias Vogel CR 0 V 0 Nightmare +3514 −0 updated 11/27/26, 10:25

Commit message

A passing test and line coverage do not show whether a test would
detect a fault in the code it executes. Mutation testing does: it
changes the code in small steps (mutants) and checks that at least one
test fails for each mutant. This matters in particular for tests
written by coding agents, which often pass but assert little.

The new suite "runTests.sh -s infection" runs Infection for the current
change. The change is the diff to the merge base with origin/main or
the closest release branch, including uncommitted and untracked files.
The suite mutates lines below Classes/ that the change modifies and
lines that changed tests execute. Each mutant runs against all unit
tests that cover its line. Mutants that no unit test detects then run
against related functional tests.

Infection's own git diff filter is not used. It only mutates changed
lines and runs the tests of a single PHPUnit configuration. A change to
tests alone would not be checked, and code that only functional tests
cover would get no mutants and be reported as success.

The suite does not run in CI. It depends on the change of the current
branch, takes several minutes, and its results need judgement, for
example for mutants that do not change the behaviour. It is a check for
the author before the change goes to review. AGENTS.md therefore
requires coding agents to run it after every code or test change and
to report the result. They aim for a mutation score of about 90 %,
which the result shows. 100 % is rarely realistic, because some
mutants do not change the behaviour.

Infection is downloaded as a PHAR on first use and verified against a
pinned SHA-256 checksum, so no Composer dependency is added.

The scripts have unit tests in Build/Scripts/infection/Tests, run with
"runTests.sh -s unit Build/Scripts/infection/Tests". Their namespace is
added to autoload-dev in composer.json.

Note the unit tests of the scripts are not part of the regular unit
test run, like the tests of the custom PHPStan rules in
Build/phpstan/tests. A dedicated patch can add the tests below Build/
to CI if needed.
Show more Show less

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 2
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/01/98101/2 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/01/98101/2 && git cherry-pick FETCH_HEAD

Review

  • Code review CR 0 Needs a vote
  • Verified V 0 Needs a vote
    • core-ci +1 CI

Merge conflicts 30

Show 25 more changes Show less

Issues 1

Files 21

Review log 24

  1. Matthias Vogel uploaded patch set 1 11/27/26, 10:11

    New local suite "runTests.sh -s infection" for mutation testing of the current change. It does not run in CI. The scripts have 108 unit tests in Build/Scripts/infection/Tests, run them with "runTests.sh -s unit Build/Scripts/infection/Tests". To be checked by others: Podman, and the PHAR download inside a container with network access.
  2. Matthias Vogel uploaded patch set 2 11/27/26, 10:17

    Patch set 2 corrects the author email of the commit. The code does not change.
  3. core-ci voted on patch set 1 V +1 11/27/26, 10:20 Copied votes on follow-up patch sets have been updated: * Verified+1 has been copied to patch set 2 (copy condition: "changekind:NO_CHANGE"). Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115703

  4. core-ci voted on patch set 2 V +1 11/27/26, 10:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/115705