Raxol.Journal.Test.ForeignBeam (Raxol Journal v2.8.0)

Copy Markdown View Source

A second BEAM OS process with every application built beside raxol_journal on its path, for tests of the journal's cross-process writer lock: a holder that is really another BEAM.

It lives until its port closes (it reads its stdin to the end), so it ends with the test process that started it. start_supervised/2 also kills it when the test exits, which covers a BEAM stuck before it reads.

For ExUnit suites: start_supervised/2 registers an on_exit callback, so it is called from a test process. Nothing else in this package calls this module.

Summary

Functions

The OS pid of a process that has exited and been reaped.

Let a BEAM started with on_go run it.

Kill the BEAM (SIGKILL, so nothing it holds is released) and wait for its exit.

The lines the BEAM printed, up to and excluding the line last.

SIGKILL without waiting, for a process that does not own the port (on_exit).

Start a BEAM that evaluates setup (Elixir source) and then waits. Returns once setup has run; pid is its OS pid. With on_go (Elixir source) it evaluates that when go/1 is called; what on_go prints, a line at a time, is read with lines_until/2.

start/2, and the BEAM is killed when the calling test exits.

Types

t()

@type t() :: %{port: port(), pid: String.t()}

Functions

dead_pid()

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

The OS pid of a process that has exited and been reaped.

go(map)

@spec go(t()) :: :ok

Let a BEAM started with on_go run it.

kill(beam)

@spec kill(t()) :: :ok

Kill the BEAM (SIGKILL, so nothing it holds is released) and wait for its exit.

lines_until(beam, last, lines \\ [])

The lines the BEAM printed, up to and excluding the line last.

signal(map)

@spec signal(%{pid: String.t()}) :: :ok

SIGKILL without waiting, for a process that does not own the port (on_exit).

start(setup \\ ":ok", on_go \\ nil)

@spec start(String.t(), String.t() | nil) :: t()

Start a BEAM that evaluates setup (Elixir source) and then waits. Returns once setup has run; pid is its OS pid. With on_go (Elixir source) it evaluates that when go/1 is called; what on_go prints, a line at a time, is read with lines_until/2.

start_supervised(setup \\ ":ok", on_go \\ nil)

@spec start_supervised(String.t(), String.t() | nil) :: t()

start/2, and the BEAM is killed when the calling test exits.