gleamunison/test_runner

Types

One test definition’s outcome: assertion tallies from the Test tape.

pub type TestResult {
  TestResult(
    name: String,
    passed: Int,
    failed: Int,
    error: option.Option(String),
  )
}

Constructors

  • TestResult(
      name: String,
      passed: Int,
      failed: Int,
      error: option.Option(String),
    )

Values

pub fn ability_ref() -> identity.DefinitionRef

The Test ability’s ref: surface-declared abilities are keyed by name hash.

pub fn attach_results(
  adapter: storage.StorageAdapter,
  results: List(TestResult),
  defs: List(#(String, elab_types.SurfaceDef)),
  cache: types.TypeCache,
) -> List(
  Result(
    #(String, identity.DefinitionRef, String),
    evidence.AttachError,
  ),
)

Attach one evidence record per test result to its subject’s hash. A test named test_foo attests the definition foo. Orphan tests (no such subject) attach nothing and are skipped in the output. Each entry: #(subject_hex, evidence_ref, payload) — the subject is what a caller verifies against; the evidence ref is where it lives.

pub fn elaborated_def_for(
  name: String,
  defs: List(#(String, elab_types.SurfaceDef)),
  cache: types.TypeCache,
) -> Result(ast.Definition, String)

Elaborate the unit and return the core definition for a name, so callers can hash the SUBJECT of a test (not the surface source).

pub fn run_suite(
  defs: List(#(String, elab_types.SurfaceDef)),
  cache: types.TypeCache,
) -> List(TestResult)

Run every test_-named definition under a recording Test handler. The runner owns loading: all non-test defs are compiled and loaded first (idempotent — handle_define unloads before loading), so test bodies may reference them at runtime. Pure sweep: results are values; nothing is stored here.

✨ Search Document