Testing doctrine
Agreed 2026-11-05. The goal is Ghostty-level test depth for the parts Voyager7 owns. libghostty-vt brings about 3,500 terminal tests of its own, and those already run on the Windows 7 VM (test-results.md). Everything between the byte source and the screen is ours and starts untested. This document says how that changes.
Rules
- Tests first. A seam gets its failing test before its implementation. A pull of work that arrives without the test is not merged.
- The oracle comes from outside our code. Where possible the expected value is produced by something we did not write: libghostty-vt, conhost, a font file, a person looking at a PNG. A test that compares the code with itself is not a test.
- Every golden image is approved by a person. Accepting whatever the code first produced is a tautology. Approval is recorded in the commit that adds the golden.
- Goldens carry their provenance. Each golden stores, beside the image, the input bytes, the font file hash and version, the size in points and pixels, the display scale, the backend (CPU reference or WARP), and the OS it was produced on. A failure must be reproducible from that record alone.
- Linux first, Windows 7 as the gate. Anything that can run as
cargo teston Linux does. The Windows 7 VM run is the release gate; the Windows 10 VM covers ConPTY. A change is not done until both VMs are green. - Replay files are the simulator. Recorded VT byte streams and recorded input event logs, with timestamps, replay through the full pipeline deterministically. The existing VT corpus is the first set.
- Budgets are tests. The budgets below are measured by scripts on the VMs and fail the build like any other test.
Seams
| # | Seam | Input and expected value | Oracle | Runs on | Status |
|---|---|---|---|---|---|
| 1 | VT bytes to screen state | .vt file, dumped screen and scrollback | Linux goldens from upstream libghostty-vt | Linux, Win7 VM | Done, 46 cases |
| 2 | Scraper diff | Console grid before and after, emitted VT bytes | Feed the bytes to libghostty-vt; its screen must equal the after grid | Linux (pure function) | Planned |
| 3 | Hook against conhost | Scripted Console API calls in a child | ReadConsoleOutput from the hidden console must equal libghostty-vt's screen | Win7 VM | Planned |
| 4 | Key events to input | Win32 key messages with modifiers, AltGr, dead keys | Expected byte sequences per mode (legacy, kitty keyboard) from the protocol specs | Linux (encoder) and Win10 VM (messages) | Planned |
| 5 | Cell geometry | Font metrics, grid size, DPI, scale | Pixel rectangles computed by hand for the cases in terminal-rendering.md | Linux | Planned, first |
| 6 | Glyph and compositor output | Text runs, fonts, sizes, scales | Approved PNG goldens from the CPU rasterizer, Ghostty sprite-test style | Linux | Planned, first |
| 7 | Rendered frame | Replay file, config | Approved PNG goldens from the D3D11 backend on WARP, read back offscreen | Win7 VM | After the renderer settles |
Seams 5 and 6 are written before any D3D11 code. Seam 2 is written before any Console API code. Seam 7 waits because goldens churn while the renderer design moves.
What each seam misses
- Seam 2 says nothing about how conhost really behaves; seam 3 covers that.
- Seam 3 does not cover timing or races between the Hook path and the Scraper fallback; those need replay files with timestamps and a soak test.
- Seam 4 does not cover the IME.
- Seam 6 does not cover real GPU output; seam 7 does, on WARP only. Real-GPU differences are checked by eye on hardware before a release.
Font fixtures
Deterministic tests use small licensed fonts checked into the repo, as COSMIC did
with its test subsets. Tests against installed system fonts are a separate,
ignored-by-default group run on the VMs, where the installed set is known.
Budgets
Measured on the Windows 7 VM under WARP unless stated. Tightening a number needs a commit; loosening one needs an ADR.
| Budget | Limit |
|---|---|
| Executable size without sidecar fonts | 5 MB |
| Launch to first presented frame | 150 ms |
| Idle CPU with the UI thread blocked | 0% |
| Keypress to presented frame | within one display refresh |
| Heap allocations per frame and per input batch, steady state | 0 |
| Memory growth over one idle hour | none |
| Windows imports newer than Windows 7 SP1, or any Universal CRT import | none |
Where things live
tests/corpus,tests/harness,tests/win7: the libghostty-vt corpus and the Windows 7 runtime tests, built with Zig. They stay as they are.- Rust unit and golden tests live beside the code in each crate; goldens under
crates/<crate>/testdata. xtaskruns the VM suites and the budget measurements and writes results todocs/test-results/.