Capstone.New.Shell (Capstone v0.33.3)

Copy Markdown View Source

The two effectful operations of the bootstrap, each behind an injected seam so every branch is reachable in-process.

The seams are not indirection for its own sake: without them the fail-loudly branches are reachable only by spawning a subprocess or installing an archive, which under minimum_coverage: 100 forces machine-coupled tests into the coverage run — and a flaky coverage gate is how a suite gets tagged out and then silently stops running.

Both defaults are literals in the function head rather than captures or named private functions. &default_runner/2 would leave defp default_runner/2 permanently uncovered, and a closure default costs an uncovered line the ignore budget cannot absorb.

Summary

Types

The injected seam ensure_task_available!/2 calls instead of Mix.Task.get/1 directly, for the same reason runner/0 is injected.

The injected seam cmd!/3 calls instead of System.cmd/3 directly, so a failure branch is reachable in-process.

Functions

Runs mix ARGS in cd, raising with the captured output on any non-zero exit.

Asserts a generator task is reachable.

Types

lookup()

@type lookup() :: (String.t() -> module() | nil)

The injected seam ensure_task_available!/2 calls instead of Mix.Task.get/1 directly, for the same reason runner/0 is injected.

runner()

@type runner() :: {module(), atom()}

The injected seam cmd!/3 calls instead of System.cmd/3 directly, so a failure branch is reachable in-process.

Functions

cmd!(args, cd, arg \\ {System, :cmd})

@spec cmd!([String.t()], Path.t(), runner()) :: binary()

Runs mix ARGS in cd, raising with the captured output on any non-zero exit.

ensure_task_available!(name, lookup \\ &Mix.Task.get/1)

@spec ensure_task_available!(String.t(), lookup()) :: :ok

Asserts a generator task is reachable.

Must be called BEFORE any dependency work: mix deps.compile prunes every archive off the code path, after which this returns nil for an archive that is still installed on disk.