Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## [Unreleased]

### Fixed

- **A whole-repository mutation run says which source files are never mutated.** A file PHP includes before Pest serves mutants (an `autoload.files` entry and what it loads, `tests/Pest.php` and what it loads), or before a bootstrap that loads the mutant itself does, is never replaced: its mutants survive whatever the tests assert, and nothing said so. The run, and `check --mutation-canary`, now list those a test covers. The score is unchanged: it still counts them. A run limited to some files already refused such a file, blaming Patchwork; it now says why.
- **No score is given when a bootstrap loads the mutant of a file PHP has already included.** Its processes die of the redeclaration and every mutant counts as caught: a file whose test asserts nothing read 100 %. Only the first source file was tried as an unchanged mutant; each file included early now is, with the canary test alone. **The bootstrap the README gave did this**: it now skips an original that `get_included_files()` lists.

## [0.1.41] - 2026-11-27

### Fixed
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ The run is parallel. A suite that fails that way (a global function a helper dec
Pest hands a mutant to its process through `PEST_MUTATION_TESTING` and `PEST_MUTATION_FILE` and serves it through a stream wrapper on `file`. If something else serves the original (Patchwork, which Brain Monkey loads, or a bootstrap), mutants survive unseen or their processes die and count as killed. After every run that has a score, in every scope, the harness therefore starts Pest as one of those processes with a "mutant" that only records that it was executed, and stops it. No record, no score: the gate fails, saying why (on the base of `changed-relative`, `base unmeasured`). A real 100 % passes, because what is judged is the record, not the value.

- **With files** (`changed`, `added`, `changed-relative`), each file is probed with the real suite. A file included without its mutant refuses the score. A file no test includes has no covered line, hence no mutant, and says nothing; but at least one file of the set must have run its mutant (the suite is tried once more with `--parallel` before concluding that none did).
- **Whole repository**, there is no single file: the harness writes `src/PolloraCanary<random>.php` and a test next to the others that loads Patchwork (when installed) and requires it, runs that test and removes both.
- **Whole repository**, there is no single file: the harness writes `src/PolloraCanary<random>.php` and a test next to the others that loads Patchwork (when installed) and requires it, runs that test and removes both. The order of the files that process included tells which source files were there before a mutant could replace them; they are listed after the score, and the same test is run once as an unchanged mutant of each: a bootstrap that loads the mutant of an included file anyway dies of the redeclaration, which would count all its mutants as caught, so that refuses the score.
**The tests must also pass on code that did not change.** A mutant's process that fails is a caught mutant for Pest, one that loops is a timeout, counted as caught too: a suite that breaks there whatever the file contains scores mutants nothing tested. So, before Pest runs:

1. **The suite runs alone** (`pest`, then `pest --parallel` if that fails, with coverage first, then without). It gives the duration and, with a coverage driver (pcov, Xdebug), which tests cover which file. When it does not pass, there is nothing to compare with.
Expand All @@ -261,7 +261,9 @@ if ($mutating) {

// Patchwork, Composer's autoloader and the helpers of the tests are loaded here

if ($mutating) {
// An original PHP has already included cannot be replaced: loading its mutant would die of the redeclaration,
// which Pest counts as a caught mutant
if ($mutating && ! in_array(realpath((string) getenv('PEST_MUTATION_TESTING')), get_included_files(), true)) {
require (string) getenv('PEST_MUTATION_FILE');
}
```
Expand All @@ -282,7 +284,7 @@ It exits 1 when no score could be believed, whatever the mode of the repository,

**Two traps of Pest's mutation runner.**
- Pest builds its `--filter` as regex alternatives, one per test that covers the mutated line. Past the PCRE compilation limit (about 64 KB) the filter is invalid, no test runs and the mutant is counted as surviving. The lines covered by almost the whole suite are the ones concerned, and adding tests can lower the score there: fewer, broader tests (datasets folded into loops) beat more of them.
- A class Composer loads from `files` (a `register.php`, a helper) is loaded before Pest mutates anything, so its mutants always survive. `--class=` does not narrow the run, and a test file edited during a run makes it die silently.
- A file PHP includes before Pest serves mutants (a class Composer loads from `files`, what that file or `tests/Pest.php` loads) is never replaced, so its mutants always survive. A whole-repository run lists those some test covers after its score (`Never mutated`), as `check --mutation-canary` does. The score is Pest's and still counts them: it is lower than what the tests deserve, never higher. A limited run refuses such a file. `--class=` does not narrow the run, and a test file edited during a run makes it die silently.

### Mutation score of the changed files

Expand Down
Loading
Loading