The run context shared by every test outcome recorded during one ExUnit suite run.
A RunContext captures where and how a suite ran: the git SHA (so
divergent outcomes on the same code can be detected), whether the
working tree was dirty, the CI provider if any, the ExUnit seed, the
test partition, and the Elixir/OTP versions.
This module is part of Temper's functional core: new/1 builds the
struct from a plain map and performs no side effects. Gathering that
map from the real environment (git, env vars, the clock) is the job
of the boundary module Temper.Env.
Summary
Types
CI information: provider name and its run identifier, if known.
Functions
Builds a RunContext from a plain map of gathered environment data.
Required keys: :run_id, :at (UTC ISO 8601 timestamp), :elixir
and :otp. Raises KeyError when any of them is missing.
Optional keys and their defaults:
:sha— current git commit,niloutside a repository:dirty— whether the working tree had uncommitted changes, defaults tofalse:branch— current git branch,nilwhen unknown:ci—%{provider: ..., run_id: ...}map,niloutside CI:seed— the ExUnit seed for this run,nilwhen unknown:partition—MIX_TEST_PARTITIONvalue,nilwhen unset
Examples
iex> context =
...> Temper.RunContext.new(%{
...> run_id: "9f1c2b3a4d5e6f708192a3b4c5d6e7f8",
...> at: "2026-08-21T14:03:22Z",
...> elixir: "1.20.2",
...> otp: "27"
...> })
iex> context.dirty
false
iex> context.sha
nil