Juggernaut.Peer.Formatter (Juggernaut v0.4.0)

Copy Markdown View Source

The ExUnit formatter of a worker's jobs (design notes §10.5): it prints nothing and sends each finished test, as a small map, to the process that runs the job.

ExUnit starts a formatter for every run with the run's configuration, where the job puts juggernaut_collector (the pid to send to) and juggernaut_job (a reference that tags every message, so a message of an earlier job is never taken for this one's). Messages:

  • {:juggernaut_started, job, {module, name}} for each test ExUnit starts;
  • {:juggernaut_test, job, outcome} for each finished test (see outcome/1). Once max_failures is reached, a test that finishes afterwards (in another async module, already running) is not reported finished, only started (docs/dependencies/exunit.md, "max_failures");
  • {:juggernaut_max_failures, job} when ExUnit stops at max_failures;
  • {:juggernaut_suite_finished, job} last.

ExUnit stops its formatters before ExUnit.run/1 returns, and a formatter handles its casts in order, so every message has been sent when the run returns.

This module runs inside workers and is never mutated.

Summary

Types

A finished test as the job reports it.

Functions

Returns a specification to start this module under a supervisor.

A finished ExUnit.Test as a small map that crosses the peer connection cheaply.

Types

outcome()

@type outcome() :: %{
  id: {module(), atom()},
  state: :passed | :failed | :excluded | :skipped | :invalid,
  time_us: non_neg_integer(),
  failure: nil | %{kind: atom(), exception: module() | nil, message: String.t()}
}

A finished test as the job reports it.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

outcome(test)

@spec outcome(ExUnit.Test.t()) :: outcome()

A finished ExUnit.Test as a small map that crosses the peer connection cheaply.