Skip to main content

Module test_json

Module test_json 

Source
Expand description

v0.59: the bynkc test --format json result model, plus the parser that folds the runner’s NDJSON event stream into it.

The generated tests/main.ts runner emits one JSON event per line when BYNK_TEST_FORMAT=ndjson (an internal protocol — proposal v0.59, Decision 2); run_test captures that stream and renders the single pinned document below. The document is built from #[derive(Serialize)] structs in declaration order — field order is the contract (the discipline bynk/src/report.rs calls out); we never use serde_json::json!, so the preserve_order feature some workspace crates enable can’t reorder it.

There are three terminal states, distinguished by the consumer on the presence/kind of error:

  • normal — suites present, no error (may have failed > 0);
  • compile — the project never compiled: no suites, error.kind == "compile" carrying the bynkc diagnostic lines;
  • runtime — the runner started then died before run-end: the observed suites prefix and error.kind == "runtime" with the captured stderr.

Structs§

Case
Coverage
The coverage block: whole-run totals plus one entry per measured .bynk file, keyed by project-relative path. Attributed to .bynk source lines, not emitted .ts/.js (issue #854); generated glue with no source origin is out-of-scope, never counted.
FileCoverage
One measured .bynk file’s line coverage.
Location
ParsedRun
The outcome of parsing the runner’s NDJSON stream: the suites observed, the running tallies, and whether a run-end event was seen (a missing run-end means the runner died mid-stream — a crashed/incomplete run).
Refusal
#2272: a step of a driven history that an agent refused. index is the step’s position in the shrunk sequence the case reports (from 0), call the handler it called, and the rest names the declaration that refused it, as Violation does.
Suite
TestError
TestRun
The pinned bynkc test --format json document.
Unmatched
The --suite and --case values a run selected nothing for (#2273), as run-end reports them: present only when a filter was given and a value went unmatched. A filter that selects nothing is an error, not a vacuous pass.
Violation
#2272: the declaration a violated invariant or transition names. kind is the declaration’s own kind, "invariant" or "transition", which the name alone cannot say (an invariant and a transition may share one).

Functions§

parse_ndjson
Parse the runner’s NDJSON stdout into a ParsedRun. Unparseable or unrecognised lines are skipped (the stream is an internal protocol; a stray line should never abort the whole report).