Skip to main content

Module testgen

Module testgen 

Source
Expand description

Test-harness generation: suite/test integration processing, the test entry (tests/main.ts), the discovery manifest and the embedded test-runtime fragments. The fragments are authored as modules under bynk-emit/runtime/src/testing/ and reach the harness only through runtime_splice (1B.3a, #4047).

1B.2a (#4028, ADR “Where test generation lives”): moved here from the driver’s project/tests_emit{.rs,/}, beside emitter. It reads no file, spawns no process and holds no thread-local; the driver keeps orchestration, file I/O and running the tests, and calls process_tests, process_integration_tests, discovery_manifest and emit_test_main. Production output never lives here: the commons barrel is emitter::commons_barrel.

P5.4 (design/tracks/semantics-in-the-checker.md §6): the checking half of process_tests/process_integration_tests — target/participant resolution, duplicate-case-name detection, stub-clause resolution, and case/property body type-checking — relocated to bynk_check::test_suites (as test_suites::phase_test_bodies/ test_suites::phase_integration_bodies), shared with bynk_check::analysis::analyse_project so a .bynk test file gets diagnostics and RefSink bindings (go-to-definition/find-references) through the LSP again, closing category 7 of bynk-check/src/analysis.rs‘s own residual-gap accounting — the last of the seven. This file keeps both functions’ exact signatures (run_checks needs no change) and everything Phase 5 (TypeScript emission) needs: the two functions now call the relocated checking phase first, then emit only for what it returns as ready. Several functions the checking phase needs are genuinely dual-use — also needed here to lower a checked body to TypeScript — and stayed pub in bynk_check::test_suites rather than being duplicated; every call into that module below is qualified (test_suites::foo(...)) for exactly that reason (see that module’s own doc comment for the full accounting).

Structs§

IntegrationD1
P5.4: test integration "name" suite processing. Validates the wires participant set (existence, ≥ 2, no duplicates, full consumes closure), type-checks each case body as a cross-context call from a synthetic harness root that consumes every participant, and emits a TypeScript module that stands the participants up as in-process Workers wired by simulated Service Bindings and runs the cases across the real serialise/deserialise wire. The checking half (participant inference, the system-needs-a-serialisation-edge gate, duplicate-case-name detection, the harness cross-context view, and per-case body type-checking) now lives in test_suites::phase_integration_bodies, which hands back each ready group’s harness resolver::CrossContextInfo — the one piece worth not recomputing here (built from clone-heavy maps). participants/uses_targets/case_inputs are cheap and pure, so the loop below recomputes them exactly as this function always did, using the now-relocated test_suites::infer_participants. The D1 inputs an integration suite is processed with: each database’s migrations, run on every test database (P4b, #2608), and the schemas they build, which a D1.peek read in a case is prepared against (#3147; None under [check] d1_sql = false).
RunnableTest
Discovered, named test ready to be invoked from the top-level runner.
TestAssetFiles
#1883, slice 3: the project’s declared assets, for the test passes — each declaration’s served path (bynk_check::assets::declared_served_paths) and each declared file’s bytes. Empty when no assets/ folder was read.

Constants§

EVAL_CASE
The name of the synthetic case. bynk-driver lowers a case of this name with its tail reported, and the run selects it by this name.
SMOKE_SUITE_SUFFIX
#2685: the tail of the synthesised smoke suite’s file name (<stem>.smoke.bynk), which a test build reads to name its typed routes to the decoder.
TEST_SESSION_KEY
#3386: the fixed signing key a SignedCookie actor’s key variable takes in a test run (base64url of 32 bytes), as the verifier refuses the short TEST_SECRET.

Functions§

discovery_manifest
v0.67: fold the combined runnable manifest into the discovery suites, ordered by the runner’s sort key (target_name) so the discovery document matches a run’s suite order.
emit_test_main
process_integration_tests
process_tests
P5.4: test <target> suite processing. The checking half (target/stub resolution, duplicate-case-name detection, case/property body type-checking — formerly this function’s own Phases 2-4) now lives in test_suites::phase_test_bodies; only a target that passed every gate comes back, keyed by its resolved stub map, so the loop below is Phase 5 (TypeScript emission) alone, over exactly the targets ready for it.