- plan/README.md: sequencing principles, milestones M1-M5, phase table with exit criteria and blocking questions, dependency graph, error-code -> phase coverage, cross-cutting tracks, task conventions - phase-0..phase-8 files: scope, invariants, task tables (P<N>-<k>) with dependencies, outputs and mechanical "done when" checks
46 lines
2.3 KiB
Markdown
46 lines
2.3 KiB
Markdown
# Testing
|
|
|
|
Non-normative. How the reference implementation is tested. Policy (what must be tested) is in `AGENTS.md`; this file covers the mechanics.
|
|
|
|
## Test levels
|
|
|
|
| Level | Where | Run | Purpose |
|
|
|---|---|---|---|
|
|
| Unit | `test` blocks in `src/`, `tools/` | `zig build test` | internal data structures, helpers, registry ↔ docs sync |
|
|
| Conformance | `tests/conformance/` | `zig build conformance` | spec behavior: accept/reject, later run output and traps |
|
|
| Reference programs | `tests/programs/` (from P2) | `zig build conformance` | the six programs in `plan/conformance-suite.md` |
|
|
| Litmus | `tests/litmus/` (from P5) | `zig build litmus` | memory-model outcomes allowed/forbidden |
|
|
| Schedule stress | via runner flags (from P3) | `zig build conformance -- --schedules=N` | randomized and systematic interleavings |
|
|
| Native parity | (from P7) | `zig build parity` | interpreter and native backend agree on the whole corpus |
|
|
|
|
Only unit and conformance exist today.
|
|
|
|
## Conformance tests
|
|
|
|
Format and outcomes: [`tests/conformance/README.md`](../../tests/conformance/README.md).
|
|
|
|
Adding a verifier rule:
|
|
|
|
1. Write the rule in the spec, with its code in `docs/reference/error-codes.md` and `src/diag.zig`.
|
|
2. Add the smallest `reject` test that violates only that rule.
|
|
3. Add an `accept` test that is as close as possible to the reject test but legal. The pair documents exactly where the boundary is.
|
|
4. Implement until both pass.
|
|
|
|
Planned header extensions (added by the phase that needs them):
|
|
|
|
| Key | Phase | Meaning |
|
|
|---|---|---|
|
|
| `expect: run` | P0 | module must verify and run |
|
|
| `stdout:` | P0 | expected output, `\n`-escaped |
|
|
| `trap:` | P0 | expected trap kind (Q-004) |
|
|
| `seed:` / `schedules:` | P3 | deterministic scheduler seed / number of randomized schedules |
|
|
| `profile:` | P2 | runtime profile (`hosted`, `deterministic`, …) |
|
|
|
|
## Determinism checks
|
|
|
|
Every run test is executed twice by the runner from P0-12 onward and the outputs (stdout, trap record, trace hash) compared byte-for-byte. Concurrency tests additionally run under the stress modes listed in `plan/conformance-suite.md`.
|
|
|
|
## Diagnostics as API
|
|
|
|
Diagnostic JSON is a stable interface. Snapshot tests on the full JSON (not only the code) belong in unit tests next to the pass that emits them, so field renames are caught.
|