Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

  1. Tests first. A seam gets its failing test before its implementation. A pull of work that arrives without the test is not merged.
  2. 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.
  3. 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.
  4. 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.
  5. Linux first, Windows 7 as the gate. Anything that can run as cargo test on 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.
  6. 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.
  7. Budgets are tests. The budgets below are measured by scripts on the VMs and fail the build like any other test.

Seams

#SeamInput and expected valueOracleRuns onStatus
1VT bytes to screen state.vt file, dumped screen and scrollbackLinux goldens from upstream libghostty-vtLinux, Win7 VMDone, 46 cases
2Scraper diffConsole grid before and after, emitted VT bytesFeed the bytes to libghostty-vt; its screen must equal the after gridLinux (pure function)Planned
3Hook against conhostScripted Console API calls in a childReadConsoleOutput from the hidden console must equal libghostty-vt's screenWin7 VMPlanned
4Key events to inputWin32 key messages with modifiers, AltGr, dead keysExpected byte sequences per mode (legacy, kitty keyboard) from the protocol specsLinux (encoder) and Win10 VM (messages)Planned
5Cell geometryFont metrics, grid size, DPI, scalePixel rectangles computed by hand for the cases in terminal-rendering.mdLinuxPlanned, first
6Glyph and compositor outputText runs, fonts, sizes, scalesApproved PNG goldens from the CPU rasterizer, Ghostty sprite-test styleLinuxPlanned, first
7Rendered frameReplay file, configApproved PNG goldens from the D3D11 backend on WARP, read back offscreenWin7 VMAfter 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.

BudgetLimit
Executable size without sidecar fonts5 MB
Launch to first presented frame150 ms
Idle CPU with the UI thread blocked0%
Keypress to presented framewithin one display refresh
Heap allocations per frame and per input batch, steady state0
Memory growth over one idle hournone
Windows imports newer than Windows 7 SP1, or any Universal CRT importnone

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.
  • xtask runs the VM suites and the budget measurements and writes results to docs/test-results/.