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:

  • normalsuites 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
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).
Suite
TestError
TestRun
The pinned bynkc test --format json document.

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).