The output formats of a run (design notes §5, §11) and the pieces they share.
Every view is a pure function of a Juggernaut.Run (and, for the live view, of the run's
events) plus options; none reads engine internals, the clock or the filesystem. The
caller supplies what a view cannot know from the run: the configured thresholds, how
timeouts are scored, the source text of the mutated files and the test files that exist.
render/3 picks a format by its --format name:
:human-Juggernaut.View.Human:agent-Juggernaut.View.Agent:json-Juggernaut.View.MTE(mutation-testing-elements):markdown-Juggernaut.View.Markdown:github-Juggernaut.View.Github
Options
:thresholds(keyword/0) - The configured thresholds (.juggernaut.exsthresholds). The default value is[].:core- Minimum score of core mutants. The default value is100.:changed- Minimum score elsewhere. The default value is80.:per- Per file or per run. The default value is:file.
:timeouts- How atimeoutkill is scored;:survivedlists it with the survivors. The default value is:killed.:page(pos_integer/0) - Page of survivors to show. The default value is1.:per_page(pos_integer/0) - Survivors per page. The default value is20.:sources(map ofString.t/0keys andString.t/0values) - Original source text by file path, for excerpts and the MTE export. The default value is%{}.:test_files(list ofString.t/0) - Test files that exist, for the suggested test file. The default value is[].:ansi(boolean/0) - Colour the human output. The default value isfalse.:report(boolean/0) - Stream: end with areportevent holding the agent document. The default value isfalse.:ci(boolean/0) - MTEsystem.ci. The default value isfalse.
Summary
Types
Where a page of survivors sits in the whole list.
A listed mutant with its result.
How a listed mutant is shown: survived, not covered, or a timeout scored as survived.
Functions
Rows of cells as left-aligned text columns, each padded to its widest cell.
The conventional test file of a source file: lib/a/b.ex → test/a/b_test.exs, and in
an umbrella apps/x/lib/a.ex → apps/x/test/a_test.exs. The first lib segment becomes
test; a path without one has its first segment replaced (gates/x.ex → test/x_test.exs).
The files of run that hold core mutants.
n followed by the singular or plural noun.
A duration for people: 850 ms, 3.1 s, 2 min 05 s.
The source lines around a mutant: from the nearest def/defp/defmacro(p) head at
most 20 lines above it (else 3 lines above) to
3 lines below. nil when the file's source was not given.
A mutant's family for people: relational:>=, or the operator alone.
The mutant of run named by ref (design notes §3): its full short id, its hash part, or
a unique prefix of 4 or more hex digits of the hash. An unknown or ambiguous ref is a
usage error (exit 2); an ambiguous one lists the candidates.
The hash part of a short id (Grant.check/2:relational:4be1c09 → 4be1c09).
The mutants killed only by integration tests (Juggernaut.Result.integration_only?/1:
every unit test of their selection passed first), core first, then by file, line and
id. They count as killed; a timeout kill scored as survived is a survivor instead
(survivors/2), so it is not listed here.
The number of the last page of page's list; 0 when the list is empty.
The command that shows the page after page of run_id's survivors, in format (nil
for human output). It always names --per-page, so following it shows the next items
whatever page size the current output used.
Validates view options, a keyword list or a map (such as one this returned), and fills
the defaults. Raises ArgumentError when invalid.
One page of items and where it sits. A page past the end is empty.
The command that shows page number of run_id's survivors at per_page a page, in
format (nil for human output).
A percentage for people: 97.4%, or - when nothing was scored.
The run's phases as {name, duration_ms}, in run order.
Renders a finished run in format (a --format name) as iodata.
The result of mutant in run; a mutant without one never ran (:pending).
The reuse note: how many results were reused and the run time recorded for them. Time saved is only ever reported from these recorded durations, never measured or estimated.
The scope of a run for people: changed vs main (2 files), full, ...
What a selection (Juggernaut.Result.selection/0) runs, for people. The run's own
counted reason, when it has one, is the result's reason.
Where a test that kills the mutant belongs: the nearest miss's test file, else the
conventional test file (lib/a/b.ex → test/a/b_test.exs) when it exists, else nil.
How a result is listed among the survivors, or nil when it is not a survivor.
The mutants listed as survivors, core first, then by file, line and id: survived and
no_coverage results, and timeout kills when timeouts are scored as survived.
The file part of a file:line test id.
The command that re-checks one mutant, in format (nil for human output).
Types
@type options() :: %{ thresholds: keyword(), timeouts: :killed | :survived, page: pos_integer(), per_page: pos_integer(), sources: %{required(String.t()) => String.t()}, test_files: [String.t()], ansi: boolean(), report: boolean(), ci: boolean() }
@type page() :: %{ page: pos_integer(), per_page: pos_integer(), total: non_neg_integer(), more: non_neg_integer() }
Where a page of survivors sits in the whole list.
@type survivor() :: {Juggernaut.Mutant.t(), Juggernaut.Result.t(), survivor_status()}
A listed mutant with its result.
@type survivor_status() :: :survived | :no_coverage | :timeout
How a listed mutant is shown: survived, not covered, or a timeout scored as survived.
Functions
Rows of cells as left-aligned text columns, each padded to its widest cell.
The conventional test file of a source file: lib/a/b.ex → test/a/b_test.exs, and in
an umbrella apps/x/lib/a.ex → apps/x/test/a_test.exs. The first lib segment becomes
test; a path without one has its first segment replaced (gates/x.ex → test/x_test.exs).
@spec core_files(Juggernaut.Run.t()) :: MapSet.t(String.t())
The files of run that hold core mutants.
@spec count(non_neg_integer(), String.t(), String.t()) :: String.t()
n followed by the singular or plural noun.
@spec duration(non_neg_integer()) :: String.t()
A duration for people: 850 ms, 3.1 s, 2 min 05 s.
@spec excerpt(Juggernaut.Mutant.t(), %{required(String.t()) => String.t()}) :: %{start_line: pos_integer(), lines: [String.t()]} | nil
The source lines around a mutant: from the nearest def/defp/defmacro(p) head at
most 20 lines above it (else 3 lines above) to
3 lines below. nil when the file's source was not given.
@spec family(Juggernaut.Mutant.t()) :: String.t()
A mutant's family for people: relational:>=, or the operator alone.
@spec find_mutant(Juggernaut.Run.t(), String.t()) :: {:ok, Juggernaut.Mutant.t()} | {:error, Juggernaut.Error.t()}
The mutant of run named by ref (design notes §3): its full short id, its hash part, or
a unique prefix of 4 or more hex digits of the hash. An unknown or ambiguous ref is a
usage error (exit 2); an ambiguous one lists the candidates.
The hash part of a short id (Grant.check/2:relational:4be1c09 → 4be1c09).
@spec integration_only(Juggernaut.Run.t(), options()) :: [ {Juggernaut.Mutant.t(), Juggernaut.Result.t()} ]
The mutants killed only by integration tests (Juggernaut.Result.integration_only?/1:
every unit test of their selection passed first), core first, then by file, line and
id. They count as killed; a timeout kill scored as survived is a survivor instead
(survivors/2), so it is not listed here.
@spec last_page(page()) :: non_neg_integer()
The number of the last page of page's list; 0 when the list is empty.
The command that shows the page after page of run_id's survivors, in format (nil
for human output). It always names --per-page, so following it shows the next items
whatever page size the current output used.
Validates view options, a keyword list or a map (such as one this returned), and fills
the defaults. Raises ArgumentError when invalid.
@spec page([term()], pos_integer(), pos_integer()) :: {[term()], page()}
One page of items and where it sits. A page past the end is empty.
@spec page_command(String.t(), pos_integer(), pos_integer(), atom() | nil) :: String.t()
The command that shows page number of run_id's survivors at per_page a page, in
format (nil for human output).
A percentage for people: 97.4%, or - when nothing was scored.
@spec phases(Juggernaut.Run.t()) :: [{String.t(), non_neg_integer()}]
The run's phases as {name, duration_ms}, in run order.
@spec render( :human | :agent | :json | :markdown | :github, Juggernaut.Run.t(), keyword() | options() ) :: iodata()
Renders a finished run in format (a --format name) as iodata.
@spec result(Juggernaut.Run.t(), Juggernaut.Mutant.t()) :: Juggernaut.Result.t()
The result of mutant in run; a mutant without one never ran (:pending).
@spec reused(%{results: non_neg_integer(), recorded_ms: non_neg_integer()}) :: String.t() | nil
The reuse note: how many results were reused and the run time recorded for them. Time saved is only ever reported from these recorded durations, never measured or estimated.
@spec scope(Juggernaut.Run.t()) :: String.t()
The scope of a run for people: changed vs main (2 files), full, ...
@spec selection_text(Juggernaut.Result.selection()) :: String.t()
What a selection (Juggernaut.Result.selection/0) runs, for people. The run's own
counted reason, when it has one, is the result's reason.
@spec suggested_test_file(Juggernaut.Mutant.t(), Juggernaut.Result.t(), [String.t()]) :: String.t() | nil
Where a test that kills the mutant belongs: the nearest miss's test file, else the
conventional test file (lib/a/b.ex → test/a/b_test.exs) when it exists, else nil.
@spec survivor_status(Juggernaut.Result.t() | nil, :killed | :survived) :: survivor_status() | nil
How a result is listed among the survivors, or nil when it is not a survivor.
@spec survivors(Juggernaut.Run.t(), options()) :: [survivor()]
The mutants listed as survivors, core first, then by file, line and id: survived and
no_coverage results, and timeout kills when timeouts are scored as survived.
The file part of a file:line test id.
The command that re-checks one mutant, in format (nil for human output).