Juggernaut.Plan (Juggernaut v0.4.0)

Copy Markdown View Source

Resolves a run's scope to files and lines, and turns them into the run's mutants (design notes §3, §10.1 steps 2-3).

Scopes:

  • :full - every .ex file under paths, less exclude;
  • :files - the named files or globs, whole (exclude does not apply to files named on purpose); a name that matches nothing is a usage error;
  • :changed - every .ex file under paths changed since the merge base of base (or the given ref) and HEAD, committed or not, plus untracked files, whole;
  • :since - only the function clauses whose lines changed since the merge base of the ref and HEAD (git diff -U0, Juggernaut.Plan.Hunks), plus untracked files whole.

A scope that needs git fails with a usage error when git cannot answer (exit 2).

Summary

Functions

Whether a mutant of module in file is core: core holds file globs and module patterns (MyApp.Core, "MyApp.Core.*").

The mutants of plan under config in lane, with short ids, plus each file's compile-time site count and the ignore errors and warnings. A file that does not parse is a usage error. In a full scan, a raw or skip route that matched no call is a warning.

The files and lines scope covers. opts: :git, the git runner (default Juggernaut.Plan.Git.run/2).

Types

file_plan()

@type file_plan() :: %{path: String.t(), lines: :all | MapSet.t(pos_integer())}

inventory()

@type inventory() :: %{
  mutants: [Juggernaut.Mutant.t()],
  files: [%{path: String.t(), compile_time: non_neg_integer()}],
  errors: [map()],
  warnings: [map()]
}

t()

@type t() :: %{scope: Juggernaut.Run.scope(), files: [file_plan()]}

Functions

core?(patterns, file, module)

@spec core?([String.t() | module()], String.t(), module() | nil) :: boolean()

Whether a mutant of module in file is core: core holds file globs and module patterns (MyApp.Core, "MyApp.Core.*").

inventory(plan, config, lane)

@spec inventory(t(), Juggernaut.Config.t(), :inner | :gate | :release) ::
  {:ok, inventory()} | {:error, Juggernaut.Error.t()}

The mutants of plan under config in lane, with short ids, plus each file's compile-time site count and the ignore errors and warnings. A file that does not parse is a usage error. In a full scan, a raw or skip route that matched no call is a warning.

resolve(config, scope, opts \\ [])

@spec resolve(Juggernaut.Config.t(), Juggernaut.Run.scope(), keyword()) ::
  {:ok, t()} | {:error, Juggernaut.Error.t()}

The files and lines scope covers. opts: :git, the git runner (default Juggernaut.Plan.Git.run/2).