API Reference mutare v#0.1.2

Copy Markdown View Source

Modules

Mutare is a mutation testing system for Elixir, that mutates the source you actually write, and compiles once.

Small constructors and predicates for Sourceror AST nodes.

Expression-level mutant generation for selector hosts and integrations.

Behaviour for describing how Mutare should treat particular calls.

The resolved argument treatments returned by Mutare.CallRouting.route_arguments/2.

Stable, resolved view of a known-macro call passed to routing and hosting callbacks.

Raised when a macro-routing provider violates the extension contract.

Call-resolution readers for custom mutators and macro integrations.

Source lines changed versus a git ref — the basis for mix mutare --since, the CI mode that mutation-tests only what a branch touched.

Translate Mutare options from an optional .mutare.exs file and CLI flags.

Read back the coverage the metamutant recorded during the probe run.

The generated-code side of coverage capture: the contract the metamutant and the test bootstrap share to record coverage synchronously, in the test process, with no race.

Parse a human duration string ("10m", "90s", "1h30m") into milliseconds.

A plugin's declared environment is not satisfied: a module it listed in Mutare.Mutator.required_modules/0 is not loadable in the Mutare process.

Non-mutating extensions that help Mutare understand source code.

A resolved non-mutating extension module and its per-instance options.

Suppresses selected mutants with a source comment. Ignored mutants remain in the report but are excluded from the mutation score.

Raised when a # mutare:ignore directive is provably wrong — a variant qualifier that can't be honoured, or a broken -start/-end region pairing — surfaced by mix mutare as a clean abort with a fix-it message, before any mutant runs.

A per-mutant map of where each mutant lives in its rendered metamutant.

The shape of a selector case subject in the metamutant.

Stable public description of one generated mutant.

Behaviour for mutators: modules that produce AST replacements.

A declarative family catalog for a family-rich mutator's configuration.

Capability behaviour for a mutator that hosts mutations inside a compile-time DSL.

One logical fragment and its mutations returned by a macro host.

A replacement AST node with optional report metadata.

A report-location override for a Mutare.Mutator.Mutation (see its :attribution field).

A resolved mutator module, report name, and per-instance options.

Behaviour for mutating positions that are larger than a single AST node: clause return values, if/unless/cond conditions, and structural pattern positions.

The registry and resolver for Mutare's built-in mutator families.

Module-alias mutations: replace a literal alias used as a value with a distinct sentinel alias (Mutare.Mutant), dropping it when the original already equals the sentinel.

Mutates arithmetic operators

Replaces a literal atom with :mutare. The replacement is omitted when the original atom is already :mutare.

Bitstring-literal mutation: collapse a non-empty <<…>> literal to the empty bitstring <<>>. The binary sibling of Mutare.Mutators.List/MapLiteral/ TupleLiteral — it asks "does anything depend on this binary's contents?". A binary that is built but whose bytes no test pins down lets <<>> survive.

Mutates Unicode encoding and byte-order specifiers in bitstring constructors. Each mutant changes one segment along one of these axes.

Mutates bitwise operators and their Bitwise function forms

Boolean-literal mutation: truefalse.

Removes a call that transforms its first argument and returns that argument instead.

Charlist-sigil mutations: replace a ~c"…" (or ~C"…") charlist with both the empty charlist ~c"" and a non-empty sentinel (~c"mutare"), dropping whichever already equals the original and preserving the sigil head (~C stays ~C). The charlist counterpart of Mutare.Mutators.StringLiteral.

Removes one clause of a multi-clause function, so inputs it handled fall through to a later clause (or raise FunctionClauseError)

Renames collection calls to a complementary operation

Changes collection calls to a related operation with fewer arguments

Replace a boolean-valued expression with the constants true and false — the "remove conditionals" mutation. Forcing a decision to one side checks that both branches it guards are actually exercised by the suite.

Replaces convention atoms with a compatible alternative

Calendar-sigil mutations: shift a date/time literal by one unit.

Drops a trailing optional argument so the call uses its default value.

Float-literal mutations: xx + 1.0, x - 1.0, and 0.0, deduplicated and never equal to x.

Changes a GenServer callback return into another valid OTP return tuple. It runs only in modules that use or declare the GenServer behaviour.

Removes a clause guard so the clause matches without its when condition

Replaces each eligible if, unless, and cond condition with true and false.

Swap complementary Integer calls for their opposite

Integer-literal mutations: nn + 1, n - 1, and 0 (the "off-by-one" boundary plus the zero sentinel), deduplicated and never equal to n.

Exchanges the two duplicate-key deletion operations for keyword lists

List operator and literal mutations

Logical/boolean operator mutations: andor, &&||, and negation stripping (not xx, !xx).

Renames Map and Keyword writes according to how they handle present and absent keys

Map-literal mutation: collapse a non-empty map literal %{…} to the empty map %{}. The map counterpart of Mutare.Mutators.List's non-empty-list collapse — it asks "does anything depend on this map's contents?". A weak suite that builds a map but never reads a key it carries lets the empty map survive.

Swap a MapSet set-combination call for its complement

Mutate calls to the Erlang :math module — the floating-point cousin of Mutare.Mutators.Numeric, asking: does any test actually depend on which trigonometric/logarithmic function (or constant) this call computes?

Replaces mode and unit atoms in supported standard-library calls. Each replacement is valid for that function and argument position.

Renames numeric selection and rounding calls to a complementary function

Reverses the first two operands of non-commutative operators and calls.

Exchanges two variables within a container in a structural pattern position

Replaces repeated variables in a pattern with _, removing the equality constraint created by the repetition

Exchanges the beginning and end of a calendar period

Mutates non-interpolated ~r sigils. Each changed token or modifier produces a separate mutant.

Positional flag-scope tracking for a regex pattern.

Relational/equality operator swaps

Narrows the exceptions handled by a rescue.

Replaces function return expressions with fixed constants.

Relaxes strict equality without changing polarity

Narrow the grapheme-aware String.length to the byte-level byte_size — the question "does this code actually depend on Unicode/grapheme semantics, or would raw byte semantics pass the suite?"

Renames string calls to a complementary operation

String-literal mutations: replace a string with both the empty string "" and a non-empty sentinel ("mutare"), dropping whichever already equals the original. So a typical non-empty string yields two mutants (empties it and swaps its content); "" yields just the sentinel; "mutare" yields just "".

Replaces a ~s or ~S sigil with the plain string literals "" and "mutare". A replacement equal to a static sigil value is omitted

Exchanges temporal ordering predicates

Tuple-literal mutation: collapse a non-empty tuple literal to the empty tuple {}. The tuple sibling of Mutare.Mutators.List/MapLiteral — it asks "does anything destructure or match this tuple?". A {:ok, value} that is built but never pattern-matched (or whose shape no test pins down) lets {} survive; anywhere the shape is used, the mutant is killed.

Replaces a non-interpolated ~w or ~W word list with an empty list and a one-element sentinel list

Validated configuration for a mutation run.

Identify compile-poisoning mutants from a failed metamutant compile.

Turns one unrecoverable compile failure into advice the user can act on.

Resolve the shape of the target into a copy-root and a mutate-scope.

Renders mutation results for the human report.

Compact diagnostics for mutants that ended as :harness_error.

Renders an HTML page that hosts the interactive mutation report.

Renders a mutation run as a mutation-testing-elements report-schema JSON document (the schema Stryker and its viewer/dashboard speak).

Live progress for the human report.

Renders surviving mutants as a SARIF 2.1.0 log.

The outcome of running the suite against one mutant.

The single descriptor registry for the Mutare.Result status vocabulary.

The completed result of a mutation-testing run.

The runtime wiring for a mutation run: the validated Mutare.Options (configuration) bundled with the things that are not configuration — the resolved Mutare.Project (copy-root + mutate-scope, derived from the target path and --app/--workspace) and the four optional live-progress hooks (reporter, on_phase, on_start, on_scan).

Compile once, then run the suite once per mutant in a fresh OS process.

Read an umbrella's declared inter-app dependency graph out of the sandbox.

Run the complete test suite green-checked against the baseline mutant (MUTARE_ACTIVE_MUTANT=0) — once, several times to catch a flaky suite, or with retries to survive an occasionally red startup run.

Decide, per mutant, which test files to run — coverage-driven test selection.

Per-worker partition slots, for DB (or any resource) isolation across the concurrent mutant runs.

Materialise a schema as a runnable copy of the target project.

Decode what a mix test mutant run did, and orchestrate one typed run.

Spawn mix against a materialised sandbox as a fresh OS process.

Read shapes out of a mix run's captured output.

The typed outcome of one mix test mutant run.

The switches that tune the one metamutant compile for speed.

Render actionable guidance for a sandbox dependency-check failure.

The mutant schema for a whole project: every in-scope source transformed into its metamutant, with globally-unique mutant ids threaded across files.

Runtime selection of the active mutant.

One mutant: a single mutation applied at a single source location.

Test helpers for projects that implement their own Mutare.Mutator.

A shipped routing-only extension for testing composition with foreign macro routing.

Source → metamutant transform, expressed as an explicit pipeline over a small intermediate representation.

Sourceror.get_range/1 with corrections for three upstream quirks that would otherwise corrupt a survivor's reported location.

Capability behaviour for overriding a use that Mutare cannot expand safely in-process.

Raised when an enabled Mutare.UseExpansion handler returns an invalid result or fails.

The directives and behaviours supplied by Mutare.UseExpansion.expand_use/3.

Mix Tasks

Mutation-test the current project.

Install Mutare and auto-configure its framework integrations.