Juggernaut.View.Live (Juggernaut v0.4.0)

Copy Markdown View Source

The human view of a run as it goes (design notes §5.1): a quiet progress line, each survivor printed as soon as it is found, then the summary.

A pure reducer over the run's events (Juggernaut.View.Stream.event/0): handle/3 takes the state, one event and the milliseconds since the run started, and returns what to write and the new state. The caller writes each {:stdout, iodata} and {:stderr, iodata} in order.

On a terminal (tty: true) the progress line (phase, mutants done of the planned total, killed, survived, no coverage when any, workers, elapsed; counted as the summary counts them, so a timeout kill is killed even when listed with the survivors) is redrawn in place on stderr and cleared before anything else is written. Otherwise there are no redraws and no control sequences: one stderr line per phase, plan, worker recycle and warning. Survivors and the summary go to stdout either way.

Options: tty (default false) and those of Juggernaut.View.

Summary

Functions

Takes one event at t_ms; returns what to write, in order, and the new state.

A live view. tty: true redraws a progress line on stderr.

The progress line of the current state, without control sequences.

Types

output()

@type output() :: [{:stdout | :stderr, iodata()}]

t()

@type t() :: %Juggernaut.View.Live{
  done: non_neg_integer(),
  finished?: boolean(),
  killed: non_neg_integer(),
  no_coverage: non_neg_integer(),
  opts: Juggernaut.View.options(),
  phase: atom() | nil,
  survived: non_neg_integer(),
  t_ms: non_neg_integer(),
  total: non_neg_integer() | nil,
  tty?: boolean(),
  workers: pos_integer() | nil
}

Functions

handle(live, event, t_ms)

@spec handle(t(), Juggernaut.View.Stream.event(), non_neg_integer()) ::
  {output(), t()}

Takes one event at t_ms; returns what to write, in order, and the new state.

new(opts \\ [])

@spec new(keyword()) :: t()

A live view. tty: true redraws a progress line on stderr.

progress(live)

@spec progress(t()) :: String.t()

The progress line of the current state, without control sequences.