Skip to content

test: run isolated tests in the process of a mutant - #722

Merged
ogorzalka merged 2 commits into
developfrom
fix/tests-in-mutant-process
Nov 27, 2026
Merged

ogorzalka merged 2 commits into
developfrom
fix/tests-in-mutant-process

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Problem

BootstrapEnvironmentTest failed on unchanged code when run the way Pest runs a mutant, so every mutant it covers counted as killed without being tested.

Cause

It uses RunTestsInSeparateProcesses. Each child runs tests/bootstrap.php again and inherits PEST_MUTATION_TESTING, but Pest's stream wrapper is not on file there, and StreamWrapper::disable() raised file:// was never changed, nothing to restore.

Fix

Give file back only when Pest's wrapper is actually on it. The mutated source is still loaded in both processes. Tests only: no CHANGELOG entry.

What this proves, and what it does not

  • Proves: a new test covers both branches; a hand-made mutant of Bootstrap.php fails exactly the 3 cases that assert it inside the isolated children, and an exact copy passes; every composer qa gate that ran locally passed (4011 tests, 1 skipped).
  • Does not prove: any mutation score; Linux (the failure was first seen on Linux CI, the fix was verified on macOS, PHP 8.4); Semgrep, gitleaks, E2E and WordPress integration were not run locally. Files listed in autoload.files still cannot be replaced by a mutant.

An upcoming harness release refuses mutation scores when tests fail on unchanged code: this has to be merged before the framework moves to it.

PHPUnit runs tests/bootstrap.php again in each process it isolates a test
in (RunTestsInSeparateProcesses). That process inherits
PEST_MUTATION_TESTING but Pest never started its stream wrapper there, so
giving `file` back raised "file:// was never changed, nothing to restore"
and failed every test of BootstrapEnvironmentTest, on unchanged code too:
every mutant those tests cover counted as killed.

The wrapper is now given back only when it is on `file`. The mutated
source is still loaded in both processes.
@ogorzalka
ogorzalka merged commit 672f5b6 into develop Nov 27, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant