Skip to content

Command line

Every command and option of vendor/bin/mutation-gate. mutation-gate <command> --help prints one command’s arguments and options in your terminal. The Decided in column links the design decision behind each option.

Commands

CommandWhat it does
mutation-gate or mutation-gate runPlan, run and judge in one process: what changed since the last commit that passed, or everything where none passed yet or run.full asks for it. With --changed-since=<ref>, only what the change since <ref> reaches; with --full, everything. With --budget=<duration>, the riskiest code first, within that time.
coverage [--into=<dir>] [--from=<dir>]Run the suite under coverage and write the gate’s own map, <dir>/map.json.gz (.mutation-gate/coverage by default), for a later plan --coverage=<dir>. With --from, run nothing and read the reports this job’s own coverage run left in that directory instead: coverage.php from --coverage-php for Pest and PHPUnit; coverage-xml/, junit.xml and clover.xml for Infection
planWork out the reach, drop proved units, cut shards and print the plan for a CI, saying first why it reaches what it does, what reaches every unit before the rest (--ci=github|gitlab|buildkite|circleci|azure|bitbucket|jenkins|json, or --shards=<n> for a fixed count; --coverage=<dir> reads the map coverage wrote instead of running the suite)
run --plan=<file> [--shard=<id>] [--results=<dir>] [--leftover=<k>]Mutate one shard: the one --shard names, or the one the CI’s environment names, and leave its result in --results; with --leftover=<k> and --shard, judge share k of the mutants that shard left at its deadline, as leftovers cut them, in its units that hold them, making only them, and leave the share’s result as <dir>/<shard>.leftover-<k>.json (ADR-0190)
verdict --plan=<file> --results=<dir>Merge every shard’s results, judge the floors, write reports and the ledger
deliver [--from=<dir>]Send what a run left in <dir> (.mutation-gate/delivery by default), with credentials that run never held: write the ledger to the store, post the comment on GitHub, GitLab or Bitbucket, as the CI it runs in says, post the alerts, and export OTLP. It runs from the gate’s own installation and loads none of the project’s code. Exits 2 where it cannot start or read the delivery, or where a trusted run’s ledger is not written to the store MUTATION_GATE_STORE names
fetch [--to=<dir>]Read the default branch’s ledger from the store with a key that only reads, and write it into .mutation-gate/fetched, where a run reads it beside the copy its own store keeps, as proofs.copies says. Written into another <dir>, a run reads it only where <dir> is the directory store’s path, and then as the copy it keeps. It runs from the gate’s own installation and loads none of the project’s code. Exits 0 where MUTATION_GATE_STORE names no store, the ledger cannot be read or the job holds no key, saying why, and 2 where it cannot start, locate the store it names, name the default branch or write the ledger
baseline [--write]Show, or write, floors raised to what was measured
survivors [--plan=<file>], with the planning options of planOn a branch’s run, run the last run’s survivors again before the shards: those the comment lists, on the change’s lines first, at most survivorsFirst.max, file by file within survivorsFirst.budget, each found again by its id, reported gone, or not re-checked where its file had no time left. It writes the comment over its planned state and the step summary, and says how many still survive. It re-checks what the plan reaches, or plans first without one; --jobs, --share and --from share it among jobs. It writes no ledger and judges nothing, so it exits 0, or 2 where it cannot re-check
leftovers --plan=<file> --results=<dir> [--coverage=<dir>]After the shards, cut the mutants each one left at its deadline into shares for a second wave of jobs, each share’s mutants grouped by source file and priced at the wall seconds a job’s split streams take over them, each test file once and each mutant’s second pass at every covering test, by the factor recent second-wave jobs measured, and each mutant no stream judged at the wall seconds its shard’s own runs took each, to fill a job that stops where shards.margin says less the time its shard took to start judging, or to come to its own runs where it came to any, every capacity growing until the matrix holds 256 jobs or fewer; write them to <dir>/leftovers.json and print the jobs’ matrix, a JSON list of each share’s shard and share, [] where no shard left any; and [], saying why on the error output, where the shards’ results alone decide the verdict: a shard left no result or one that cannot be judged, or a shard stopped once the run could not pass (ADR-0190, ADR-0196, ADR-0301, ADR-0336)
reproduce <id>Run one recorded mutant again, alone, and show why it survives, with the runner’s own output; the id may be a unique prefix of 6 or more. Exits 1 where the run finds other than what was recorded, and 2 where no ledger holds it or the run no longer makes it
explain <id> [--format=text|json]Show one mutant’s diff, hint, covering tests and their outcomes, for a kill by static analysis the analyser and its finding’s file, code and message, how the last run took its unit, and its history, from the ledgers and the last run, running nothing; the id may be a unique prefix of 6 or more, or a cluster’s id. --format=json is described by resources/explain.schema.json. Exits 2 where no record holds it
digest [--detail=<file|id|legend>] [--survivors=<n|all>] [--tests=<n>]Say the last run’s verdict one fact a line, for an agent or a terminal, from the JSON report every verdict keeps at .mutation-gate/report.json, running nothing: the verdict, why, what to do, the counts each with its grade, each set, where the verdict comes from, the warnings, and the first 25 survivors, or as many as --survivors asks for, each with what test would catch it. With --detail, one target in depth instead: a file, a mutant by its id or a unique prefix of 6 or more, naming as many of its covering tests as --tests or digest.tests says, 5 by default, a cluster, or legend for what each word means (reading the report). Exits 2 where no run left a report, it cannot be read, a count is no whole number, or the target names nothing the run holds
affected [--changed-since=<ref>] [--coverage=<dir>] [--format=files|files0|ids|json]List the tests the change since the coverage map was measured can make fail, and with --changed-since the change since <ref> besides, running nothing: each test file a line (files, for PHPUnit 13’s --test-files-file), each ended by a NUL byte (files0, for xargs -0 vendor/bin/pest, or vendor/bin/phpunit on PHPUnit 12), each test id a line (ids, for PHPUnit 13.2’s --test-id-filter-file), or the JSON answer. The reasons go to standard error but in JSON. A map that is missing, does not say where it was measured or was measured in a dirty tree lists every test. Exits 0 whenever it answered, and 2 where git cannot tell what changed or ids cannot select the tests
testsPrint the tests report of the last run, judged again from the ledgers and the coverage map it left, running nothing: the useless, redundant and weakly asserting tests. Exits 0 whatever it finds, and 2 where no run has left one
mutators [--format=text|json] [--ledger=<file>]Print what each mutator costs and finds, from the tally the default branch’s ledger keeps, or the ledger.json.gz --ledger names: one row for each mutator of each runner, the costliest first, with its mutants, kill rate, survivors, runner time, time per kill and share of every mutator’s time, running and writing nothing. Each run that writes a ledger and judges every mutant adds to the tally. --format=json is described by resources/mutators.schema.json (ADR-0076). Exits 0 once printed, and 2 where the ledger cannot be read
machine [-- <program>…]Print this machine as one JSON object: its processor’s cpu where Linux names it, and its cores. Given a program, it runs it once untimed and then 5 times, each round timed from the program’s start to its exit, and adds rounds and their median seconds; the program’s output goes to standard error. CI scales the local budgets by it (ADR-0159). It reads no config. Exits 0, and 2 where a round of the program did not end with 0
triage <path> [--repeat=<n>] [--order=runner|killers-first]Run a unit, a file of a tree or a held path, n times (5 by default, 2 or more) and list every mutant whose result varied, with the runs that gave each result, each mutant’s tests in the order --order names (tests.order by default). Exits 1 where a mutant varied, 0 where none did, and 2 where the unit cannot be run
watchRe-judge what each save reaches; in the daemon that serves the project, started where none runs and local.serveStart is watch
lsp [--severity=error|warning|information|hint] [-- <watch option>…]Serve an editor as a language server on standard input and output: run watch --output=events in the workspace’s root, with every other option given and those after --, and show each survivor as a diagnostic over the line its site starts on, coded with its id, a warning by default, with code actions that run explain, stub and stub --write for it (ADR-0133). --stdio, which editors pass, is the only transport. Exits 2 where no Outbreak binary is in use
serve [--stop] [--detached]Keep the gate loaded for the project, listening on .mutation-gate/serve.sock, and run watch, pre-commit and pre-push there, each in a child of its own, until no request comes for local.serveIdle, a request finds the gate’s version, composer.lock or the config changed since it started, or serve --stop stops it. pre-commit and pre-push use a daemon only where one runs, and each of the three runs on its own where no daemon serves it. --detached leaves the session of the command that started it, as watch starts it
pre-push [<remote> [<url>]] [--stdin=<lines>]Judge the commits being pushed, as CI will, after printing each reached tree’s score change. The refs come from git’s lines on standard input, from --stdin where a hook manager read them, as CaptainHook does, or, where neither holds a line, from the variables the pre-commit framework sets. Each line must be a local ref, its commit, a remote ref and its commit, each commit a full object name in hex
pre-commitPrint each reached tree’s score change from the local ledger; runs nothing and always exits 0
hook install [--pre-commit] / hook uninstallAdd or remove the pre-push hook, and with --pre-commit the pre-commit hook too
init [--format=php|json|yaml|neon] [--ci[=github|gitlab|buildkite|circleci|azure|bitbucket|jenkins]] [--editor=vscode] [--hook[=git|captainhook|grumphp|pre-commit]] [--no-hook] [--native=allow|refuse] [--dry-run] [--no-measure]Detect the runner, preset, trees, CI and an Infection config; where no config is here, ask in turn what detection leaves open: the runner where both are installed, the CI where the files show none or several, whether to import the Infection config found, what to do with the runner’s own ignore markers found, where to set the pre-push hook up, and whether to add composer mutate to the scripts in composer.json, each defaulting to what detection found, and asking nothing with --no-interaction, with no terminal, or in CI; write a config holding the runner and the preset it found (PHP by default, or the file --config names, in the format of its extension), listing the trees the tree source finds in a comment, or for JSON in what it says, and add .mutation-gate/ to .gitignore; with --ci, a pinned CI definition (--ci alone takes the detected CI), with --editor, VS Code’s watch task, and with --hook, the hook, each only where none exists, and otherwise what to add to it; run the suite once under coverage and say what a full run takes, cut into shards as the config asks, with the hot paths nothing holds; then say what to run next: doctor, the first run, and git add of the files it wrote
init --from[=<file>] or import [<file>] [--format=php|json|yaml|neon] [--no-measure]Write a config from an Infection config, the file named or the one Infection itself would read, over what zero-config found; say of each of its keys whether it was imported, stays in that file or was dropped, and which keys to delete; then say what a full run takes, as init does
doctor [--measure] [--online] [--format=text|json] [--fix [--yes]]Report what would fail, run slowly or deserves attention, each with its fix, reading only files and earlier runs; exits 1 when something would fail. --fix shows the diff of every file it can fix and what it cannot fix, then asks once whether to write them; --yes answers yes, and with no terminal to ask and no --yes it writes nothing. It turns opcache off and loads pcov in the php.ini the runner’s PHP loads, where it can write it, and names pecl install pcov rather than running it; lowers the PHPUnit config’s memory_limit to runner.memory; adds the trees to its <source>; adds .mutation-gate/ to .gitignore; applies pest:patch and infection:patch; and pins the installed release in each CI definition. Once it wrote, it looks again and exits as doctor does (ADR-0083). --fix writes text, so it refuses --format=json
stub <id> [--style=pest|phpunit|phpspec] [--write]Print a failing Pest or PHPUnit test or PhpSpec example for a survivor or an uncovered mutant, or one for a cluster, in the style of its nearest covering test, found as explain finds the mutant, with Try: … and its scaffold calling the function with the values rules found to kill the survivor where they found any (ADR-0101); with --write, add it to that file, or create one, never overwriting. Exits 2 where there is nothing to stub, with the next step where there is one, and under the Codeception and Testo runners, whose tests are in no style it writes
dashboard --org=<org> --out=<dir> [--include-private]Build an organisation’s dashboard into <dir>: index.html, one page with no script or style it loads, and dashboard.json, from each repository’s summary.json on its mutation-gate branch, read through GitHub’s API with GITHUB_TOKEN, for the repositories with dashboard.topic or those dashboard.repositories names. Private and internal repositories are left out unless --include-private is given, which it accepts only where GitHub says the Pages site of GITHUB_REPOSITORY is private (ADR-0024). Exits 2 where it was not given both options, the config cannot be read, GitHub cannot list the repositories, private ones may not be shown, or it cannot write
config:show [--format=…] [--resolved] / config:schemaPrint the effective config (JSON by default), each context block as written, or with --resolved as a run in its contexts reads it; or the JSON Schema
config:suggest [--ledger=<file>]Print the config changes the ledger gives evidence for, each with its evidence: of the runner the config chooses, an idle mutator, which costs time and finds nothing, and a noisy one, whose mutants are mostly ignored or equivalent, turned off by mutators.except, and a paths entry doubling the timeout of a directory whose mutants run out of time, by the suggest.* thresholds; then the config file with them laid over it, as a unified diff in its own format. A change the config cannot say is named with why, and left out of the diff. It writes nothing (ADR-0076). Exits 0 whatever it suggests, and 2 where the config or the ledger cannot be read
migrate [--write]Show the diff that moves the config and the baseline to the current release, and with --write, write it. A PHP config keeps its comments and layout, and only the builder calls a release retired change. A JSON config and the baseline change key by key. A YAML or NEON config is written again, and its comments are not kept. The baseline is the one the config names, or mutation-gate.baseline.json while the config does not read. A change migrate cannot make is listed for a hand edit. Exits 0 where every file is current or written, 1 where a change is pending without --write or left for a hand edit, and 2 where a file cannot be read
pest:patchApply the optional Pest patches (ADR-0004). Exits 0 once they are applied, and 2 where one cannot be
infection:patchGive Infection the gate’s mutant limit (ADR-0004). Exits 0 once it is applied, 1 where the installed Infection is not a release of 0.35.0 to 0.35.15, and 2 where Composer’s installed.json cannot be read, lists no Infection, or a change cannot be applied. In post-install-cmd, a non-zero exit fails composer install

Options

OptionAccepted byWhat it doesDecided in
--config=<path>every command but deliver and fetchRead this config file instead of looking for one0002
--no-extensionsevery command but deliver and fetchLoad only the extensions of this package and its first-party plugins, and no third-party code0001
--context=<local|ci|github|gitlab|bitbucket|azure|buildkite|jenkins|circleci|pr|main>every command but deliver and fetchPut the run in this context, and in ci beneath a CI’s, pr and main, whose blocks under contexts it lays, instead of the one the environment and the CI plan tell; watch, pre-commit and pre-push are in local without it0071
--deliver-laterplan, survivors, verdictSend nothing that needs a credential and write no store: leave the ledger and the comment, alert and OTLP payloads in .mutation-gate/delivery/planned, .mutation-gate/delivery/survivors or .mutation-gate/delivery/verdict, begun empty, for deliver; on a pull request the comment is left whether or not the job holds a token0007
--runner=<name>every command but deliver and fetchSet runner0002
--report=<name>:<path>every command but deliver and fetch, repeatableAdd a file report to reports0002
--changed-since=<ref>plan, run without a plan, survivors, affectedMutate, or list the tests of, only what the change since <ref> reaches; last-passed, the default of plan and run, is the newest passing commit; last-run, for plan and run off the default branch, reads the change from the commit the scope’s last run of the same kind judged, falling back to the fetched default branch0005
--fullplan, run without a plan, survivorsMutate everything, whatever the event and run.full; an error beside --changed-since0005
--unprovenplan, run without a plan, survivorsMutate everything and take no proof, so every unit runs whatever the ledgers hold: the backstop of a key that reads only the gate’s verdict code; an error beside --changed-since0084
--sampleplan, run without a plan, survivorsRun a sample of the units no run knows exactly, tree by tree, sized by sampling.margin and drawn from sampling.seed, and judge each tree on its estimated score’s interval: passed where its lower bound reaches the floor, failed where its upper bound is below it, and otherwise undecided, which is exit code 2. New code, a unit a change-scoped run reaches, and every tree at a floor of 100 run in full. A sampled run records no commit as passed, raises no floor, judges no security set, and updates neither the badge, the trend nor the alerts; an error beside --security or --suite. Every shard and the verdict follow a plan made with it0020
--budget=<duration>every command but deliver and fetchSet budget: stop after this long, riskiest code first, such as 90s, 15m or 1h30m; watch and pre-push take it in place of local.watchBudget and local.prePushBudget0008
--coverage=<dir>plan, run without a plan, survivors, affectedRead the coverage an earlier job wrote instead of running the suite0006
--selection-onlyplanStop at the selection: write the units the plan runs, with why it reached them, as one uncut shard, measuring no held coverage, handing no shard its map and taking no timing, and hand it to no CI. plan.json is marked selectionOnly, and run --plan, verdict, leftovers and survivors refuse it, since it holds no mutant time limit0290
--from=<dir>coverageRead the reports this job’s own run of the suite under coverage left in this directory instead of running the suite0006
--into=<dir>coverageThe directory to write map.json.gz into, .mutation-gate/coverage by default0006
--from=<dir>deliverThe delivery to send, .mutation-gate/delivery by default0007
--jobssurvivorsPrint the jobs a CI shares the re-check among, as {"shares":[1,2],"minutes":30}: one per file of the survivors it takes, at most survivorsFirst.shards, none where it takes none, and the minutes each may take; one, saying why aside, where the survivors cannot be told. Re-checks nothing0106
--share=<i>survivorsRe-check the i-th share of the files of survivors, counted from 1, beside --of, and leave what it made in .mutation-gate/survivors/<i>.json0106
--of=<n>survivorsHow many jobs share the re-check, beside --share or --from0106
--from=<dir>survivorsReport the survivors with what the --of shares left in this directory, a share that left nothing not re-checked0106
--to=<dir>fetchWhere to write the default branch’s ledger, .mutation-gate/ledger by default0007
--from[=<file>]initStart from an Infection config: this file, or the one Infection would read0016
--ignores-for=<days>init, importHow many days each ignore imported from an Infection config lasts, 90 by default0016
--ci[=<name>]every command but deliver and fetchSet ci.plan: this CI’s format instead of the detected one. With init, also write that CI’s definition, or the detected CI’s where it names none0006
--shards=<n>plan, run without a plan, survivorsCut exactly n shards0006
--securityplan, run without a plan, survivorsMake mutants with the security-tagged mutators alone, and judge only the security sets: each tree is shown exempt, and no commit is recorded as passed. Every shard and the verdict follow a plan made with it0021
--suite=<name>plan, run without a plan, survivorsJudge the mutants by this PHPUnit <testsuite>’s tests alone, the coverage run’s among them, and hold no floor: each tree and security set is shown exempt, unless --security keeps the security sets held, and no commit is recorded as passed. Takes no --coverage. Every shard and the verdict follow a plan made with it0025
--plan=<file>run, verdict, survivorsThe plan the shards and the verdict follow0006
--shard=<id>run with a planThe shard to mutate, instead of the one the CI names0006
--leftover=<k>run with a plan and --shardJudge share k of the mutants the shard left at its deadline, as leftovers cut them0190
--results=<dir>run with a plan, verdictWhere each shard leaves its result, and where the verdict reads every one0006
--output=console|problemsrun, watch, pre-pushproblems prints one <path>:<line>:<col>: <severity>: <message> [<rule>] <id> line per result, for editors; console, the default, prints the console report0015
--output=eventswatchPrint one line of JSON per judged mutant as its batch ends, and one as each round ends, {"round", "mutants", "why"} (judged, changed, invalid or unjudged; how many mutants it printed; why it judged none). A mutant’s line is {"mutant", "site", "status", "by", "quick", "unit", "digest"}, the status killed, survived, timeout, pending or equivalent, and no verdict0146
--whole-reportwatchEnd each round with the whole report; without it, where local.streamBatches is on, the console prints only one block per unit as each batch ends0146
--only=changedrun, watch, pre-push with --output=problemsPrint only the mutants on changed lines0015
--writestubAppend the stub to its nearest covering test file, or create one; never overwrite0015
--writemigrateWrite the migrated config and baseline0026
--writebaselineWrite the raised floors to the baseline, rather than showing them0003
--format=<format>init, import, config:show, explain, doctor, affectedThe format written: php, json, yaml or neon for the config init and import write (php by default) and config:show prints (json by default); text or json for explain and doctor; files, files0, ids or json for affected (files by default)0002, 0020
--resolvedconfig:showPrint the config of a run in the contexts it is in, or those --context names, with their blocks laid and contexts dropped, naming the contexts on standard error0071
--editor=vscodeinitSet VS Code up: its watch task, in .vscode/tasks.json, and the SARIF Viewer recommended in .vscode/extensions.json0015
--detail=<file|id|legend>digestOne file, mutant or cluster in depth, or legend for what each word means0009
--survivors=<n|all>digestHow many survivors the overview lists, 25 by default0009
--tests=<n>digestHow many of a mutant’s covering tests its detail names, in place of digest.tests0009
--repeat=<n>triageHow many times to run the unit, 2 or more, 5 by default0013
--order=runner|killers-firsttriageThe order of each mutant’s tests, tests.order by default0013
--pre-commithook installAlso add the pre-commit hook, which shows the score change and never blocks0010
--org=<org>, --out=<dir>, --include-privatedashboardThe organisation, the directory the dashboard is written to, and whether private and internal repositories are shown0024
--style=pest|phpunit|phpspecstubThe stub’s style, instead of the nearest covering test’s0015
--dry-run, --stdoutinitPrint every file, the config and the line .gitignore would gain among them, instead of writing it0015
--sharded, --singleinit --ci=githubThe reusable workflow or the one-step action, instead of the one the estimated cost picks0015
--hook[=git|captainhook|grumphp|pre-commit], --no-hookinitAnswer the hook question: git’s own pre-push hook, which a bare --hook means, or the hook manager’s config calling the gate: CaptainHook’s captainhook.json, GrumPHP’s grumphp.yml or the pre-commit framework’s .pre-commit-config.yaml; where the manager reads a config already, print what to add to it. --no-hook sets no hook up0017, 0024
--native=allow|refuseinitAnswer the native-markers question: allow writes ignores.native: allow, refuse leaves the default0017
--no-measureinit, importEstimate a full run from lines of code, rather than from a coverage run of the suite0017
--stdin=<lines>pre-pushThe lines git handed the hook, from a hook manager that read them: CaptainHook’s {$STDIN}0024
--measuredoctorAdd one coverage run: a green suite, a working driver and the hot paths0017
--onlinedoctorAlso read GitHub’s settings with the token: the required verdict, the fork approval policy, the schedule0017
--kill-matrix=first|fullplan, run, survivorsfull records every test that kills each mutant, for the redundant-test report (Pest, and the PHPUnit, PhpSpec, Codeception and Testo runners)0014
--publish-dir=<dir>verdict, run without a planWhere the badge and trend are written, .mutation-gate/publish by default0009

Arguments

ArgumentTaken byWhat it is
<id>reproduce, explain, stubA mutant’s id, or a unique prefix of 6 or more; explain and stub also take a cluster’s id
<path>triageThe unit: a file of a tree, or a held path
install or uninstallhookWhether to add the hooks or remove them
<file>importThe Infection config to import; the one Infection itself would read where none is named
<remote>, <url>pre-pushThe remote pushed to and its URL, as git hands them to the hook

Exit codes

CodeMeaning
0Passed
1Failed
2Could not judge

Could not judge means, for example, an invalid config, an opening test run that failed, a shard with no results, a command line the gate cannot read, a command it does not know, or a failure it did not anticipate. A failed verdict is always 1, and nothing else is. run with a plan exits 0 once its shard’s result is written, because the verdict judges it, and 2 when it cannot write it, the plan belongs to another commit, or the CI’s shard count differs from the plan’s. verdict exits 2 where the plan belongs to another commit, or where a shard’s result stands in the place of another shard.