# `Juggernaut.Coverage`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/coverage.ex#L1)

Coverage for a run (design notes §10.5): which tests each mutant runs.

`run/3` takes the booted pool and the build, decides what to probe from the coverage
index (`Juggernaut.Coverage.Index.stale/2`), probes those test files
(`Juggernaut.Coverage.Probe`), updates the index, and gives every mutant its selection
(`Juggernaut.Coverage.Selection`): the tests that hit its site, the whole file, the
whole suite (with the reason), the boot lane, or none (`no_coverage`).

# `id`

```elixir
@type id() :: {module(), atom()}
```

# `result`

```elixir
@type result() :: %{
  index: Juggernaut.Coverage.Index.t(),
  selections: %{required(String.t()) =&gt; Juggernaut.Coverage.Selection.t()},
  probed: %{required(String.t()) =&gt; Juggernaut.Coverage.Probe.file_result()},
  stale: {:all, String.t()} | {:files, %{required(String.t()) =&gt; String.t()}}
}
```

# `boot_keys`

```elixir
@spec boot_keys([pos_integer()], %{required(pos_integer()) =&gt; [Juggernaut.Mutant.t()]}) ::
  MapSet.t(String.t())
```

The keys of the mutants of the boot set's sites.

# `inventory`

```elixir
@spec inventory(%{required(id()) =&gt; %{file: String.t(), excluded?: boolean()}}) :: %{
  required(String.t()) =&gt; [id()]
}
```

The runnable (not excluded) tests of the boot inventory, by test file.

# `run`

```elixir
@spec run([Juggernaut.Mutant.t()], keyword()) ::
  {:ok, result()} | {:error, Juggernaut.Error.t()}
```

Coverage of `mutants` (each with its `switch`). Options:

  * `:workers` (required) - `[{index, pid}]` of the booted pool;
  * `:info` (required) - a worker's boot info: the test inventory and the boot set;
  * `:sites` (required) - the build's sites, first switch → switches;
  * `:current` (required) - the project's hashes (`Juggernaut.Coverage.Index.current/4`),
    to which the keys of `mutants` are added (`Juggernaut.Coverage.Index.keys_by_source/1`);
  * `:index` - the index read from disk (`nil` when none);
  * `:durations`, `:seed`, `:timeout_ms` - as `Juggernaut.Coverage.Probe.run/3`.

# `selections`

```elixir
@spec selections(
  [Juggernaut.Mutant.t()],
  %{required(String.t()) =&gt; [Juggernaut.Coverage.Selection.label()]},
  MapSet.t(),
  map()
) :: %{required(String.t()) =&gt; Juggernaut.Coverage.Selection.t()}
```

Each mutant's selection by its id, from the labels by key and the boot keys.

# `site_mutants`

```elixir
@spec site_mutants(%{required(pos_integer()) =&gt; [pos_integer()]}, [
  Juggernaut.Mutant.t()
]) :: %{
  required(pos_integer()) =&gt; [Juggernaut.Mutant.t()]
}
```

Each site (first switch) with its mutants, from the build's `sites`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
