Search by

uams-web / patches-pest-plugin-mutate

joshdaughertybpmore

Patches UAMS-Web repositories apply to pestphp/pest-plugin-mutate

Package info

github.com/UAMS-Web/patches-pest-plugin-mutate

Language:JavaScript

pkg:composer/uams-web/patches-pest-plugin-mutate

Statistics

Installs: 40 019

Dependents: 29

Suggesters: 0

Stars: 0

Open Issues: 36

v1.6.1 2026-12-01 13:02 UTC

README

Patches that UAMS-Web repositories apply to pestphp/pest-plugin-mutate with cweagans/composer-patches 2.x. One package replaces the copies each repository carried, so a patch is changed once and retires everywhere in one release.

This package pins pestphp/pest-plugin-mutate to exactly 5.0.2. Every patch is written against that release.

Install

This package is read from GitHub with a vcs repository, not from Packagist. The consumer's root composer.json lists it (Composer reads repositories only from the root project):

"repositories": [
  { "type": "vcs", "url": "https://github.com/UAMS-Web/patches-pest-plugin-mutate.git" }
]

An application requires it in require (the plugin applies a dependency's patches only from packages in composer.lock):

composer require --no-plugins uams-web/patches-pest-plugin-mutate:^1.0

A package that another repository installs requires it with --dev and lists the patch files in its own root patches.json. The full procedure, including composer patches-relock and composer patches-repatch, is the upstream-patch-lifecycle skill's Moving a consumer to the package.

Patch paths are relative to the consumer's root and start vendor/uams-web/patches-pest-plugin-mutate/patches/, so a consumer with a non-default vendor-dir is not covered.

Patches

Applied in this order, which is the order of the list in composer.json, a JSON array so that the order survives Packagist (an object's keys come back in another order there). A later patch is cut against the output of the earlier ones, so none is reordered without re-cutting those after it.

  • pest-plugin-mutate-mutant-process-launch.patch: Launch each mutant child process so a run cannot score every mutant killed without executing one (temporary; see #2322)

  • pest-plugin-mutate-annotation-parsing.patch: Stop three silent @pest-mutate-ignore parsing defects suppressing nothing or the wrong set (temporary; see #2327)

  • pest-plugin-mutate-windows-mutant-child.patch: Let a mutant child on Windows run its tests and write files, so its failure is a real kill (temporary; see #2524)

  • pest-plugin-mutate-drop-run-filter.patch: Drop the run's own --filter from each mutant child so a filtered run cannot score every mutant killed (temporary; see #2570)

  • pest-plugin-mutate-windows-filter-length.patch: Widen or refuse a mutant child's filter that PCRE cannot compile, or that would pass cmd.exe's command-line limit on Windows, so it cannot score a kill without running a test (temporary; see #2578, #3114)

  • pest-plugin-mutate-write-mutated-source.patch: Create the mutations directory, write each mutated source through a temporary file renamed into place, fail on a mutated source that cannot be written (naming the reason the write or rename gave), and rebuild a cached mutation whose mutated file is missing or whose contents no longer hash to its name, so a run cannot score mutants it never applied (temporary; see #2812, #147)

  • pest-plugin-mutate-drop-parallel-runner-options.patch: Drop the parallel runner's options (--passthru-php, --processes and the rest) from each mutant child so a parallel run given one cannot score every mutant killed (temporary; see #2926, #2947)

  • pest-plugin-mutate-function-defaults.patch: Select tests for a mutated function, method, closure or arrow function parameter default, whether a bare literal or one inside a negation, array or arithmetic expression, so it is not scored without a test running the function (temporary; see UAMS-Web/uams-2020#673)

  • pest-plugin-mutate-no-test-check.patch: Score a mutant child that ran no test as untested, not killed, and go on with the run, except for the child that crashed after printing a failed test, after PHPUnit named the test a fatal error ended, after a fatal error named the mutated file (code that does not compile), after PHP's time limit ended it, after the hard memory limit ended it, after Windows reported a stack overflow (exit -1073741571), or after the code's own exit ended it while a test was running (PHPUnit's events log shows a test prepared and not finished), which is scored killed because the mutated code is what failed, and drop the run's own --log-junit from each child, which Pest refuses beside the child's own (temporary; see UAMS-Web/UAMSWP-Logo-List#82, #27, #34, #40, #41, #45, #58, #60, #64)

  • pest-plugin-mutate-class-constant-coverage.patch: Map a class constant mutant to the tests covering its containing class, and generate it under --covered-only when any line of that class is covered, since a constant initializer has no executable coverage line (temporary; see #47) It maps a mutant inside a constant's initializer in a class, interface, trait or enum only. Class constant visibility mutants (ConstantPublicToProtected, ConstantProtectedToPrivate), enum case values and global const declarations are not mapped and stay uncovered. A constant mutant prints its own line; only the lookup of covering tests uses the whole class. The patch is cut against the output of pest-plugin-mutate-function-defaults.patch and does not apply to stock alone. Clear vendor/pestphp/pest-plugin-mutate/.temp/pest-mutate-cache after adopting or retiring a patch that changes which mutants are generated, because the cache key does not record the patches.

  • pest-plugin-mutate-ignore-annotated-statement.patch: Skip a node whose own comment carries a matching @pest-mutate-ignore marker, including when the traverser still leaves that node (temporary)

  • pest-plugin-mutate-mutant-timeout.patch: Size a mutant child's time limit from the serial work the initial suite stands for, using the worker count the initial run used (--max-processes included), so a --parallel run cannot score a mutant a timeout that no test caused; a mutant that loops is stopped at that limit, so it takes up to that many times as long to score in a --parallel run, and a serial run is unchanged (temporary; see #2, #126)

  • pest-plugin-mutate-stream-wrapper-patchwork.patch: Keep Patchwork in front of the mutation stream wrapper after a pass-through read, so a function a test mocks is still redefined in a mutant child that logs to junit (temporary; see #31)

  • pest-plugin-mutate-mutant-timeout-retry.patch: Run a mutant child again when it times out once, and score a timeout only when the second attempt times out too and a third run without the mutation finishes a passing report inside the limit; a mutant that a slow covering test file overruns, or whose third run ends any other way, is scored untested, so a surviving mutant is not scored caught by a one-off slowdown; a looping mutant costs two more runs, about 16.4 to 17.5 s against about 9.8 s at a 5 s limit, measured serial on Windows (temporary; see #30, #56, #127)

  • pest-plugin-mutate-url-stat-unreadable.patch: Report an existing file that cannot be read as present from the mutation stream wrapper's url_stat(), so code that reads it behind an is_file() or file_exists() check reaches the read in a mutant child, and report a dangling symlink as a link; on Windows is_readable() then reports a file whose read access is denied as readable, which it does not without the wrapper (temporary; see #52, #122)

  • pest-plugin-mutate-isolated-process-activation.patch: Give a mutant child the autoloader path PHPUnit needs to start a test run in a separate process, so such a test is no longer scored killed for failing to start, and start the mutation stream wrapper in an isolated PHPUnit child, which has no Pest kernel and so never runs Mutate::boot(), once the project lists src/Autoload.php under its root autoload.files, so an isolated test sees the mutated source; a stale or empty variable no longer stops a process that loads that file (temporary; see UAMS-Web/UAMSWP-Logo-List#82, #125). Split from the no-test check in #92, so each is reported and retired on its own

  • pest-plugin-mutate-coverage-report.patch: Let a mutation run load the coverage report named by PEST_MUTATE_COVERAGE_REPORT instead of running the whole suite to produce one, and leave that report in place so another run can load it; a report that does not exist or cannot be loaded fails the run naming its path, and PEST_MUTATE_SUITE_SECONDS gives the mutant time limit the suite duration the skipped run did not measure (temporary; see #138)

Each description names the ticket that tracks the upstream fix, or the consumer ticket that moved the patch here where no upstream ticket exists. The text after each file name is the description composer.json lists the patch with, character for character; node scripts/check-patch-descriptions.mjs fails when the two differ, and the Patches workflow runs it.

Isolated tests

A test that runs in a separate process (#[RunInSeparateProcess], or processIsolation in phpunit.xml) needs one step from the consumer before a mutation run can kill a mutant through it. Measured on Windows 11, PHP 8.4.27, Pest 5.3.7 and pestphp/pest-plugin-mutate 5.0.2 (macOS and Linux were not run), with an isolated test that asserts the value of the mutated line:

Setup Isolated test in a mutant child Mutants on its line
Without pest-plugin-mutate-isolated-process-activation.patch fails to start (Class "PHPUnitTextUIConfigurationRegistry" not found) scored killed, whatever the test asserts
With the patch, no consumer step runs against the original source survive
With the patch and the consumer step runs against the mutated source killed when the assertion fails

The consumer step lists the patched file in the root composer.json and rebuilds the autoloader:

"autoload": { "files": ["vendor/pestphp/pest-plugin-mutate/src/Autoload.php"] }
composer dump-autoload

To retire the patch, remove that entry and run composer dump-autoload first, then remove the patch. With the entry in place and the file gone (the patch not applied, or retired), every PHP process of the project fails at vendor/autoload.php with Failed opening required.

The file starts the wrapper only when PEST_MUTATION_TESTING and PEST_MUTATION_FILE both name a file that exists, so a stale or empty variable leaves an unrelated process alone. The child is started with PHPUnit's defaults, which replay none of the parent's included files, so the autoloader is the only thing that starts the wrapper in it.

Mutating from an existing coverage report

A --mutate run starts with a full run of the selected suite under coverage, then generates mutants. With pest-plugin-mutate-coverage-report.patch, a run that names a coverage report skips that run:

# once, wherever the suite can run: write the report
vendor/bin/pest --coverage-php=coverage.php

# in each run that mutates: load it instead of running the suite
PEST_MUTATE_COVERAGE_REPORT=coverage.php PEST_MUTATE_SUITE_SECONDS=600 vendor/bin/pest --mutate --path=src
  • PEST_MUTATE_COVERAGE_REPORT is the path of a PHP report as --coverage-php writes it. A relative path is read from the working directory. The run loads the test files without running a test, scores mutants from the report, and leaves the file where it is, so any number of runs can load the same one. It needs no coverage driver. The run's own --filter and --coverage* options are dropped from the run that loads the test files, since a second --filter is refused and a --coverage-php naming the report would write an empty one over it.
  • A report that does not exist, or cannot be loaded, fails the run with a message naming its path.
  • PEST_MUTATE_SUITE_SECONDS is how long the suite takes run serially. The plugin sizes each mutant child's time limit from the initial run's duration, and a run that skips the suite has none; without this variable the limit is sized from the few seconds spent loading the test files.
  • The report is not checked against the source or the tests. Produce it from the same code the run mutates.
  • With PEST_MUTATE_COVERAGE_REPORT unset, a run behaves as 5.0.2 does: it runs the suite under coverage and removes its own report.

Versioning and verification

The wiki documents each patch, using the package, which change makes which release (Versioning), and what tests/check.sh applies and asserts on every pull request (Verifying the set). Its pages are kept in docs/wiki/ and published from there.

License

MIT, see LICENSE. The patches modify pestphp/pest-plugin-mutate, which is also MIT licensed.