ClientUtils.RunLink (client_utils v0.4.2)

View Source

A run's link to the CodeMySpec harness that started it.

The harness names itself in the run's environment: CMS_HARNESS_NODE, CMS_HARNESS_COOKIE and CMS_RUN_ID, and optionally CMS_RUN_LISTENER, the process to report to (by default the harness's CmsHarness.RunLink). The run joins that node and sends each event, numbered, to that process.

A run outlives its harness. Its events are held until the harness acknowledges them; when the harness goes, the run carries on, rejoins a harness that adopts it, and replays what was not acknowledged (ClientUtils.RunLink.Session). The run does not exit until its last event, its exit status, is acknowledged.

Its output goes to CMS_RUN_OUTPUT, not the harness's pipe, so nothing it prints fails once that pipe is gone.

A run started with none of these runs as a plain mix test.

Summary

Functions

Report the run's exit status and wait until a harness has every event. Its first caller decides the status; the run's exit, which calls it again, waits on the same report. A runner that halts (sexy_spex does) skips the exit, so the formatter reports it when the suite finishes.

Join the harness named in the environment, or nil when none is named. A second join in the same run returns the same link.

Send this BEAM's stdio to path, appended: :user and :standard_error are re-registered to file devices and every process whose group leader was the old :user follows. The devices belong to the caller, which must outlive every test. Also for a run's parent task (mix cms.spex), which prints its shards' output and must survive the harness's pipe closing too.

Send one event to the harness. A run without a link sends nothing.

Types

t()

@type t() :: %ClientUtils.RunLink{run_id: integer(), session: pid()}

Functions

finish(arg1, status)

@spec finish(t() | nil, integer()) :: :ok

Report the run's exit status and wait until a harness has every event. Its first caller decides the status; the run's exit, which calls it again, waits on the same report. A runner that halts (sexy_spex does) skips the exit, so the formatter reports it when the suite finishes.

join(opts \\ [])

@spec join(keyword()) :: t() | nil

Join the harness named in the environment, or nil when none is named. A second join in the same run returns the same link.

redirect_output(path)

@spec redirect_output(Path.t()) :: Path.t()

Send this BEAM's stdio to path, appended: :user and :standard_error are re-registered to file devices and every process whose group leader was the old :user follows. The devices belong to the caller, which must outlive every test. Also for a run's parent task (mix cms.spex), which prints its shards' output and must survive the harness's pipe closing too.

report(arg1, event)

@spec report(t() | nil, map() | nil) :: :ok

Send one event to the harness. A run without a link sends nothing.