# `Juggernaut.Cache.Weakening`
[🔗](https://github.com/holsee/juggernaut/blob/v0.4.0/lib/juggernaut/cache/weakening.ex#L1)

Whether the tests were weakened since a cached result was recorded (design notes §7.3),
from the patch of the test paths and `config/` between the entry's commit and the
working tree (untracked files read as added lines).

Findings, each naming its file:

  * `:assertions_deleted` - a test module lost more assertion lines (`assert*`,
    `refute*`) than it gained;
  * `:skip_tag` - an added `@tag`, `@moduletag` or `@describetag` with `skip`, or with
    one of the tags the test helper excludes;
  * `:exunit_configured` - `ExUnit.configure` or `ExUnit.start` added in a test module;
  * `:test_deleted` - a test module deleted;
  * `:support_changed` - any file that is not a test module (`*_test.exs`) changed: test
    support, the helper, fixtures, config, or a test module renamed to something that
    is not one (named by its new path);
  * `:binary` - a binary change (or an untracked file that cannot be read).

A tag counts only as code at the start of a line, not quoted inside a test. Any finding
invalidates every cached entry of that commit (`Juggernaut.Cache`), and every finding is
surfaced in the run's summary. Adapted from the mutation-cache gate of an earlier
project by the same author, with assertion deletions added.

# `finding`

```elixir
@type finding() :: %{
  kind: kind(),
  file: String.t(),
  detail: String.t() | nil,
  commit: String.t() | nil
}
```

# `kind`

```elixir
@type kind() ::
  :assertions_deleted
  | :skip_tag
  | :exunit_configured
  | :test_deleted
  | :support_changed
  | :binary
```

# `check`

```elixir
@spec check(Path.t(), [String.t()], [String.t()], Juggernaut.Plan.Git.runner()) :: %{
  findings: [finding()],
  failed: [String.t()]
}
```

The findings of each commit in `commits` (each with its `commit`), and the commits git
could not diff against (`failed`; their entries cannot be trusted either). Diffs
`test_paths` and `config` with `git` (`Juggernaut.Engine.Checkout.quiet/2`).

# `excluded_tags`

```elixir
@spec excluded_tags({:ok, String.t()} | {:error, term()}) :: [String.t()]
```

The tags excluded in a test helper's source, given as a `File.read/1` result: the
atoms and keyword keys of every literal `exclude: [...]` list, in order. A test tagged
with one does not run. An unreadable or unparsable helper excludes nothing.

# `findings`

```elixir
@spec findings(String.t(), [String.t()]) :: [finding()]
```

The findings of a unified diff (see the module doc); `excluded` are tag names.

---

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