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

Which tests a mutant runs, from the probe's labels (design notes §10.5).

A mutant's labels are those of every hit on its site, across every probed test file
(`Juggernaut.Peer.Recorder`, with the controller's `{:file, file}` for a job's own
hits). The selection, first rule that applies:

  1. `:boot` - the site ran while the app started or the tests loaded: the boot lane
     (§10.8), whatever else hit it, since no job runs that code again. Its `warm` key
     holds the selection the labels give by the rules below, for the tests that run
     the code again after boot: the mutant is tried with them on a warm worker first;
  2. `:suite` - a hit no test or test file owns (a cast, a timer, a message, a call
     from a process no test owns): the whole suite, with the reasons;
  3. `:file` - a hit owed to a test file but no single test (`setup_all`, `on_exit`,
     a process they started): every test of those files, plus the tests that hit it;
  4. `:tests` - the tests that hit it;
  5. `:none` - nothing hit it: `no_coverage`, no job.

A `:suite` or `:file` selection also keeps `hits`: the tests that hit the site
themselves, sorted. They are the likeliest killers, so `Juggernaut.Runner.Schedule`
runs them first (D2).

Test ids are `{module, name}`. Labels kept in the coverage index name them by strings
(`Juggernaut.Coverage.Index`); `select/3` takes either.

# `id`

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

# `label`

```elixir
@type label() ::
  {:test, id() | {String.t(), String.t()}}
  | {:file, String.t()}
  | {:none, {atom(), String.t()}}
```

# `t`

```elixir
@type t() :: %{
  optional(:warm) =&gt; t(),
  optional(:hits) =&gt; [id()],
  selection: :boot | :suite | :file | :tests | :none,
  tests: [id()] | :all,
  reason: String.t() | nil
}
```

# `describe`

```elixir
@spec describe({atom(), String.t()}) :: String.t()
```

A readable form of an unattributed hit's reason.

# `select`

```elixir
@spec select([label()], boolean(), %{required(String.t()) =&gt; [id()]}) :: t()
```

The selection of a mutant whose site has `labels` (`boot?` when it is in the boot
set), given `inventory`: each test file's runnable tests, `%{file => [id]}`. A label
for a test not in the inventory is dropped (the test is gone or excluded).

# `string_id`

```elixir
@spec string_id(id()) :: {String.t(), String.t()}
```

A test id as the coverage index keeps it: `{module, name}` as strings.

---

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