lightspeed/testing

Helpers for deterministic runtime tests.

Types

Event output collected by the deterministic interpreter.

pub type EventRecord {
  EventRecord(name: String, payload: String)
}

Constructors

  • EventRecord(name: String, payload: String)

Serializable log entry for one executed instruction.

pub type LogEntry {
  LogEntry(
    step: Int,
    instruction: isa.Instruction,
    opcode: String,
    summary: String,
  )
}

Constructors

  • LogEntry(
      step: Int,
      instruction: isa.Instruction,
      opcode: String,
      summary: String,
    )

Patch output collected by the deterministic interpreter.

pub type PatchRecord {
  PatchRecord(target: String, html: String)
}

Constructors

  • PatchRecord(target: String, html: String)

Deterministic interpreter state for ISA simulation.

pub type SimulationState {
  SimulationState(
    mounted_route: option.Option(String),
    rendered_views_rev: List(String),
    patches_rev: List(PatchRecord),
    pushed_events_rev: List(EventRecord),
    subscriptions_rev: List(String),
    navigation_to: option.Option(String),
    shutdown_reason: option.Option(String),
    telemetry_rev: List(String),
    errors_rev: List(String),
  )
}

Constructors

  • SimulationState(
      mounted_route: option.Option(String),
      rendered_views_rev: List(String),
      patches_rev: List(PatchRecord),
      pushed_events_rev: List(EventRecord),
      subscriptions_rev: List(String),
      navigation_to: option.Option(String),
      shutdown_reason: option.Option(String),
      telemetry_rev: List(String),
      errors_rev: List(String),
    )

A deterministic trace of instructions emitted by a test run.

pub type Trace {
  Trace(opcodes: List(String))
}

Constructors

  • Trace(opcodes: List(String))

Values

pub fn errors(state: SimulationState) -> List(String)

Validation errors in execution order.

pub fn instructions(log: List(LogEntry)) -> List(isa.Instruction)

Extract instructions from a log.

pub fn mounted_route(
  state: SimulationState,
) -> option.Option(String)

Route from the latest mount instruction, when mounted.

pub fn navigation(
  state: SimulationState,
) -> option.Option(String)

Latest navigation target, when present.

pub fn opcodes(trace: Trace) -> List(String)

Extract opcodes from a trace.

pub fn patches(state: SimulationState) -> List(PatchRecord)

Patches in execution order.

pub fn pushed_events(state: SimulationState) -> List(EventRecord)

Pushed events in execution order.

pub fn rendered_views(state: SimulationState) -> List(String)

Rendered view ids in execution order.

pub fn replay(log: List(LogEntry)) -> SimulationState

Replay a prior log into a deterministic interpreter state.

pub fn run(program: List(isa.Instruction)) -> SimulationState

Run an ISA program through the deterministic test interpreter.

pub fn run_with_log(
  program: List(isa.Instruction),
) -> #(SimulationState, List(LogEntry))

Run an ISA program and return a replayable instruction log.

pub fn shutdown_reason(
  state: SimulationState,
) -> option.Option(String)

Shutdown reason, when a shutdown instruction was executed.

pub fn subscriptions(state: SimulationState) -> List(String)

Subscriptions currently active at end of simulation.

pub fn telemetry(state: SimulationState) -> List(String)

Telemetry messages in execution order.

pub fn trace(instructions: List(isa.Instruction)) -> Trace

Build a trace from an instruction list.

Search Document