Swift edition
mutastic run
Mutate the package and run its tests against each mutant. DIR is the SwiftPM package's directory, the one with its Package.swift, here unless given. The run passes when the score reaches the threshold, or with --fail-on-new when every mutant no test catches is in the baseline. A full run, one without --only or --at, writes report files, and offers the commands to work on each missed mutant. Its progress goes to stderr, so stdout holds only the result. --shard runs one share of the mutants, for splitting a run across CI jobs, and --from-shards puts the shares back together as the whole run. A package that needs an argument to build, a define or a trait to turn on, say, gets what follows -- on the line, for swift build.
Usage
mutastic run [DIR] [OPTIONS]A coding agent's hooks run it as the command: the build plugins don't.
Output
On the pricing sample, where one mutant gets past the tests. This is mutastic's own output, written from the CLI and checked against it on every build.
Missed ────────────────────────────────────────────────────────────
❯ Sources/Pricing/Pricing.swift 1 missed in 1 function
✗ MISSED no test checks discount() at total == 100 ┌─ Sources/Pricing/Pricing.swift:12 │ 11 │ public func discount(total: Int) -> Int { 12 │ if total >= 100 { │ ^^ >= changed to > 13 │ return total / 10 │ = mutant - if total >= 100 { + if total > 100 { = operator mutastic/boundary · https://docs.mutastic.io/swift/operators/conditions/#boundary = note: every test calls discount() away from the boundary inputs seen: 50, 250 (none is 100) covered by PricingTests.bigOrdersGetTenPercentOff(), PricingTests.smallOrdersPayFullPrice() (all 2 covering tests still pass) = help: test discount() with total = 100 and assert the result
// in Tests/PricingTests/PricingTests.swift @Test func discountAtTheTotalEdge() { #expect(Pricing().discount(total: 100) == 10) // today 10 · with this mutant 0 } check today's value is the one you intend: the test pins what the code does now
done when mutastic verify m86f9a31d samples/pricing passes reproduce mutastic run --only=m86f9a31d samples/pricing or ignore mutastic ignore m86f9a31d --reason="<why>" samples/pricing
Next: mutastic verify <id> samples/pricing · mutastic run --only=<id> samples/pricing · mutastic explain <id> samples/pricing
Files 0 clean | 1 with misses Mutants ✓ 10 caught · ✗ 1 missed (11) Worst at Pricing.discount() 1 ✗ Build one build of every mutant, 1 round (build) Test runs 14 (33 without coverage selection) Start at 22:28:54 Duration 7.3s (setup 35ms, build 7.1s, coverage 22ms, mutants 115ms, checking 22ms, reports 23ms) Tests 3 on swift 6.3.3 · 4 workers Reports samples/pricing/.build/mutastic/mutation.json · samples/pricing/.build/mutastic/mutation.html Score 90.9% PASS 1 missed, above the threshold of 80.Exit status
0 when the score reaches the threshold, 1 when it doesn't; with --fail-on-new, 0 when every mutant no test catches is in the baseline, 1 when one isn't; with --only or --at, 0 when each mutant named is caught or skipped, as verify judges it, and 1 while one is still missed or not covered. Any command exits 2 when mutastic couldn't run: see exit codes.
Options
--threshold=N
The score a run must reach to pass, a whole number from 0 to 100; 80 unless set.
| Command line | --threshold=N |
|---|
--fail-on-new
Pass when every mutant no test catches is in .mutastic/baseline.yaml, and fail on one that isn't, whatever the score: the threshold isn't applied. For a package whose score can't reach it yet; mutastic baseline writes the file.
| Command line | --fail-on-new |
|---|
--since[=REF]
Mutate only the lines changed since the merge-base of HEAD and REF, uncommitted and new files included; the default branch without one. With no mutant on those lines, nothing is built or run.
| Command line | --since[=REF] |
|---|
--only=ID
Run one mutant, or several split by commas, whatever --operators says.
| Command line | --only=ID |
|---|
--at=PATH:LINE
Run, or list, only the mutants on a line of a source file, or with :FROM-TO on those lines, under the run's operators; several split by commas. The run passes when each is caught or skipped.
| Command line | --at=PATH:LINE |
|---|
--workers=N
How many mutants run side by side; half the cores, from 1 to 4, unless set.
| Command line | --workers=N |
|---|
--confirm-catches
Run each catching test again on its own, to confirm the catch.
| Command line | --confirm-catches |
|---|
--kill-matrix
Run every test that reaches a caught mutant, to name each that catches it, not only the first: for measuring an order, slower.
| Command line | --kill-matrix |
|---|
--shard=N/M
Run only the Nth of M shares of the mutants, to split one run across machines. It keeps its results in shares/N-of-M in .build/mutastic for --from-shards.
| Command line | --shard=N/M |
|---|
--from-shards=DIR
Run no mutants: put together the results every share of a split run kept, found anywhere in DIR, as the whole run, with its reports and threshold.
| Command line | --from-shards=DIR |
|---|
--no-suggestions
Don't look for a test that catches each missed mutant, which runs the missed mutant's function outside the tests.
| Command line | --no-suggestions |
|---|
--force-coverage
Build and run every test even when no mutant is there to run, to check or time the suite.
| Command line | --force-coverage |
|---|
--exclude-tests=TEST
A test to leave out of the run, by its name as a run shows it, or a module of tests by its path: one that can't run reliably here, with a race or a fixed port; the summary names it, and says so of a name that matches no test. mutastic.yaml's exclude-tests: leaves one out of every run, with its reason.
| Command line | --exclude-tests=TEST |
|---|
--build-system=BUILD
Which build a directory with both a Package.swift and an Xcode project uses: the one with tests unless set, and a refusal when both have them.
One of swiftpmxcode
| Command line | --build-system=BUILD |
|---|
--scheme=SCHEME
The Xcode scheme whose tests a run uses, for a project or workspace with several: the only one with tests for macOS or iOS unless set.
| Command line | --scheme=SCHEME |
|---|
--operators=OPERATORS
Which operators run: a set (defaults, stronger, extended or all), an operator's id or namespace, or any with - in front to leave it out, in place of mutastic.yaml's operators; defaults unless set.
| Command line | --operators=OPERATORS |
|---|
--report=KIND[:PATH]
A report file a full run writes: json (mutation.json), html (mutation.html) or sarif (mutation.sarif), in .build/mutastic unless a path is given, or none; json and html unless set.
One of jsonhtmlsarifnone
| Command line | --report=KIND[:PATH] |
|---|
--format=FORMAT
How the result is shown; full on a terminal, concise elsewhere, agent for coding agents; explain takes full and jsonl.
One of fullbriefconcisegroupedagentjsonl
| Command line | --format=FORMAT |
|---|---|
| Environment | MUTASTIC_FORMAT, MUTASTIC_AGENT |
--each-mutant
A card for every missed mutant, not one for the mutants of each line.
| Command line | --each-mutant |
|---|
--vocabulary=WORDS
plain says caught and missed; classic says killed and survived.
One of plainclassic
| Command line | --vocabulary=WORDS |
|---|---|
| Environment | MUTASTIC_VOCABULARY |
--color=WHEN
Colour: auto uses it on a terminal that wants it.
One of autoalwaysnever
| Command line | --color=WHEN |
|---|---|
| Environment | NO_COLOR, FORCE_COLOR |
--hyperlinks=WHEN
File locations as links a terminal can open: auto uses them on a terminal.
One of autoalwaysnever
| Command line | --hyperlinks=WHEN |
|---|
--progress=STYLE
Progress on stderr: redrawn in place on a terminal, a line every 30 s in logs, CI and agents' runs, or none.
One of autobarcounternone
| Command line | --progress=STYLE |
|---|---|
| Environment | MUTASTIC_PROGRESS |