Juggernaut.Triage (Juggernaut v0.4.0)

Copy Markdown View Source

The committed triage file, .juggernaut.triage.json (design notes §7.4): claims that a mutant is equivalent (no test can tell it from the original), each with its reason, who made it and the hash of the mutated function when it was made.

A claim's state against a run (state/3):

  • :lapsed - the function's hash changed (or the function is gone): the claim no longer says anything and the mutant runs;
  • :unacked - a claim on core code that no human has acknowledged: the mutant runs and the claim is surfaced in the summary;
  • :applies - the mutant is equivalent, not run and not scored.

The file is sorted by key and pretty-printed with keys in a fixed order, so a claim's diff reads well in review. A claim made again for the same mutant replaces the old one and drops its acknowledgement.

Summary

Functions

triage with the claim on key acknowledged by name at at.

triage with a claim that mutant is equivalent, for reason, by by (or nil), at at (an ISO 8601 string), resting on the mutated function's current function_hash.

The triage of a run's mutants: an equivalent result for each mutant whose claim applies, and one claim map per claimed mutant of the run (id, core, acked, state, reason, by), as the summary shows them. hash gives a mutant's current function hash (function_hash/2).

The file's text: entries sorted by key, keys in a fixed order, 2-space indent.

The triage file's name, relative to the project root.

The entry query names (a short id, its hash part, a unique prefix or the key).

The current hash of mutant's function in the project at root (nil when its file cannot be read), memoised per file in cache (a map; pass the returned one on).

The current hash, in file of the project at root, of the function a mutant key (or a claim's key) names; as function_hash/3.

The triage file of the project at root.

The triage of the project at root: empty when there is no file.

triage without the claim on key.

The state of entry given the mutated function's current hash (nil when the function is gone) and whether the mutant is core now (see the module doc).

Writes triage to the project at root (sorted, pretty-printed, atomic).

Types

entry()

@type entry() :: %{required(String.t()) => term()}

state()

@type state() :: :applies | :unacked | :lapsed

t()

@type t() :: %Juggernaut.Triage{entries: [entry()]}

Functions

ack(triage, key, name, at)

@spec ack(t(), String.t(), String.t(), String.t()) :: t()

triage with the claim on key acknowledged by name at at.

claim(triage, mutant, function_hash, reason, by, at)

@spec claim(
  t(),
  Juggernaut.Mutant.t(),
  String.t(),
  String.t(),
  String.t() | nil,
  String.t()
) :: t()

triage with a claim that mutant is equivalent, for reason, by by (or nil), at at (an ISO 8601 string), resting on the mutated function's current function_hash.

classify(triage, mutants, hash)

@spec classify(t(), [Juggernaut.Mutant.t()], (Juggernaut.Mutant.t() ->
                                          String.t() | nil)) :: %{
  results: [Juggernaut.Result.t()],
  claims: [map()]
}

The triage of a run's mutants: an equivalent result for each mutant whose claim applies, and one claim map per claimed mutant of the run (id, core, acked, state, reason, by), as the summary shows them. hash gives a mutant's current function hash (function_hash/2).

encode(triage)

@spec encode(t()) :: String.t()

The file's text: entries sorted by key, keys in a fixed order, 2-space indent.

file_name()

@spec file_name() :: String.t()

The triage file's name, relative to the project root.

find(triage, query)

@spec find(t(), String.t()) :: {:ok, entry()} | {:error, Juggernaut.Error.t()}

The entry query names (a short id, its hash part, a unique prefix or the key).

function_hash(root, mutant, cache \\ %{})

@spec function_hash(Path.t(), Juggernaut.Mutant.t(), map()) ::
  {String.t() | nil, map()}

The current hash of mutant's function in the project at root (nil when its file cannot be read), memoised per file in cache (a map; pass the returned one on).

key_hash(root, file, key, cache \\ %{})

@spec key_hash(Path.t(), String.t(), String.t(), map()) :: {String.t() | nil, map()}

The current hash, in file of the project at root, of the function a mutant key (or a claim's key) names; as function_hash/3.

path(root)

@spec path(Path.t()) :: Path.t()

The triage file of the project at root.

read(root)

@spec read(Path.t()) :: {:ok, t()} | {:error, Juggernaut.Error.t()}

The triage of the project at root: empty when there is no file.

revoke(triage, key)

@spec revoke(t(), String.t()) :: t()

triage without the claim on key.

state(entry, current_hash, core?)

@spec state(entry(), String.t() | nil, boolean()) :: state()

The state of entry given the mutated function's current hash (nil when the function is gone) and whether the mutant is core now (see the module doc).

write(root, triage)

@spec write(Path.t(), t()) :: :ok | {:error, Juggernaut.Error.t()}

Writes triage to the project at root (sorted, pretty-printed, atomic).