MutagenEx.Test.CoverFacade behaviour (mutagen_ex v0.2.0)

Copy Markdown View Source

Behaviour for the OTP :cover test seam used by MutagenEx.CoverageRunner.

Production code talks to the :cover Erlang module (lifted from lib/tools-*/ebin on first use); the facade exists so tests can swap a fake recording stub and assert on the lifecycle (start, compile, analyse, stop) without touching the real cover_server.

Default

MutagenEx.Test.Cover delegates to :cover.

Summary

Types

Result of :cover.analyse/3 with :coverage + :line.

Result of :cover.compile_beam/1.

Result of :cover.start/0.

Callbacks

Analyse coverage for an instrumented module. Mirrors :cover.analyse(module, :coverage, :line).

Instrument a .beam for coverage. Mirrors :cover.compile_beam/1.

Start the cover_server. Mirrors :cover.start/0.

Stop the cover_server. Mirrors :cover.stop/0.

Types

analyse_result()

@type analyse_result() ::
  {:ok, [{{module(), pos_integer()}, {non_neg_integer(), non_neg_integer()}}]}
  | {:error, term()}

Result of :cover.analyse/3 with :coverage + :line.

compile_beam_result()

@type compile_beam_result() :: {:ok, module()} | {:error, term()}

Result of :cover.compile_beam/1.

start_result()

@type start_result() :: {:ok, pid()} | {:error, {:already_started, pid()}} | term()

Result of :cover.start/0.

Callbacks

analyse(module, type, granularity)

@callback analyse(module :: module(), type :: atom(), granularity :: atom()) ::
  analyse_result()

Analyse coverage for an instrumented module. Mirrors :cover.analyse(module, :coverage, :line).

compile_beam(path)

@callback compile_beam(path :: charlist()) :: compile_beam_result()

Instrument a .beam for coverage. Mirrors :cover.compile_beam/1.

path is the charlist returned by :code.which/1; the runner does the conversion at the call site.

start()

@callback start() :: start_result()

Start the cover_server. Mirrors :cover.start/0.

stop()

@callback stop() :: any()

Stop the cover_server. Mirrors :cover.stop/0.