Juggernaut.Store.Runs (Juggernaut v0.4.0)

Copy Markdown View Source

Whole runs on disk: runs/<run_id>/run.json and runs/<run_id>/mutants.ndjson (design notes §7).

run.json is the Juggernaut.Run without mutants and results. Each line of mutants.ndjson is {"format": 1, "mutant": ..., "result": ...} in mutant order (result is null for a mutant without one). Both files are written atomically, and mutants.ndjson first: run.json is the commit marker. A run is listed only once its run.json exists, so an interrupted write never shows as a run, and a listed run whose mutants.ndjson is missing is an error rather than a run without mutants.

Summary

Functions

Run ids under root that have a run.json, newest first.

Loads a whole run (mutants and results included).

Loads the newest run that was scored: one that was not ended by an infrastructure error (its summary.error is null). A run ended that way (exit 3) is recorded for profile, history and report, but it stopped part way and holds few or no results, so the previous killers, check and triage read the last scored run instead (design notes §7.2). A run that finished with verdict error because some mutants are harness_error is scored: it holds all its results, and its ids are the ones the user just saw. None: a usage error (exit 2).

Resolves a run reference to a run id: {:latest, n} is the n-th newest (0 = newest), {:id, id} or a bare id must exist. Unknown: a usage error (exit 2).

Writes a run's files under root, which must be a prepared store (Layout.check/1).

Types

ref()

@type ref() :: {:latest, non_neg_integer()} | {:id, String.t()} | String.t()

Functions

list(root)

@spec list(Path.t()) :: [String.t()]

Run ids under root that have a run.json, newest first.

load(root, ref)

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

Loads a whole run (mutants and results included).

load_scored(root)

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

Loads the newest run that was scored: one that was not ended by an infrastructure error (its summary.error is null). A run ended that way (exit 3) is recorded for profile, history and report, but it stopped part way and holds few or no results, so the previous killers, check and triage read the last scored run instead (design notes §7.2). A run that finished with verdict error because some mutants are harness_error is scored: it holds all its results, and its ids are the ones the user just saw. None: a usage error (exit 2).

resolve(root, id)

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

Resolves a run reference to a run id: {:latest, n} is the n-th newest (0 = newest), {:id, id} or a bare id must exist. Unknown: a usage error (exit 2).

write(root, run)

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

Writes a run's files under root, which must be a prepared store (Layout.check/1).