Testing Strategy¶
Note
How the shell is tested: which layers get which kind of test, what runs without a display, what needs a compositor, how the budgets are checked, and what stays a manual checklist. Written before M0 so the first code has tests from the start (ADR-0016 Staged Development). It leans on what tre offers for tests with no display (App.simulate, Window.simulate, Window.advance, Window.snapshot, Window.frame_stats, all seen in the installed tre 0.5.9 on 2026-11-02; the tre guide for each was not re-read, #needs-verification). Proposal for the maintainer.
Purpose and Scope¶
- Give each layer a test kind, a marker and a place to run.
- Name what is checked automatically and what is checked by hand.
- Not in this note: the
tess_dlcorpus (owned bytess-dl, TDL Library API), tre's own tests, and security testing (to follow the security model).
Test Layers¶
| Layer | What is tested | How | Needs |
|---|---|---|---|
| Unit | Config discovery, the registry, validation, the schema, the value store, TEL scope and tracking, error records | pytest on plain Python; no tre |
Nothing |
| Files | Loading a shell file from text: tess_dl parse, Import, names, the UID write, positions in errors |
pytest with small .tdl strings and the tess_dl corpus |
tesserae-dl |
| Binder | The block and key tables, the converters, links, update, rebuild by key, error positions | A headless tess_re.Window built in the test; read properties back from nodes; Window.advance for animation; Window.snapshot for a few reference images |
tre, no display |
| Binder tables vs docs | The block and key tables agree with the "tre" columns of Block Reference and Style Schema | A test parses the doc tables and compares | The vault notes (a copy under tests/data/, refreshed by a script) |
| Surfaces | Anchor, size, margin, exclusive zone computed for a Bar, Panel, Popup, Frame; monitor matching; output events | Unit tests on the geometry functions (pure Python), with App.simulate("output_added", ...) for outputs |
Nothing for the maths; a compositor for the windows |
| Layer windows | A real LayerWindow appears, reserves space, takes input |
A headless sway in CI, as tre does; a manual run on KWin | A wlroots compositor; KWin by hand |
| D-Bus | The service layer, the control interface, the KWin script's call | A private session bus (dbus-daemon), fake services written with dbus-fast |
dbus-daemon |
| Modules | The module contract: start, stop, send, actions, a failing module | A fake context; a real Clock against a fake time source |
Nothing |
| Hot reload | A file change reaches the screen with the keyed diff | Write a file, trigger the reload, assert the node changes and unchanged nodes are not touched | Binder test setup |
| Performance | The budgets in Performance Budgets | Scripts that time parse, bind and update; an idle-CPU measurement of a running shell | A normal desktop |
| Accessibility | Roles and names exist on the nodes the Block Reference promises | Read the node properties; later, tre's accessibility tree | tre |
| Manual | KWin behaviour, fullscreen hiding, multi-monitor, shortcut registration, portal changes | A written checklist per milestone, run by the maintainer | A KDE session |
Markers and What Runs by Default¶
| Marker | Meaning | In the default run |
|---|---|---|
| (none) | Unit, files, module and geometry tests | Yes |
tre |
Needs tess_re, including the run tests that start a private headless sway (tests/sway.py) |
Yes, if tess_re imports and sway is found; skipped with a clear reason otherwise (as built at M0) |
dbus |
Needs dbus-daemon |
Yes, if found |
compositor |
Needs a running Wayland compositor | No; run in the sway job and by hand |
perf |
Timing and idle-cost checks | No; run on request |
manual |
A checklist item | No; listed, never run |
Where Tests Run¶
- Local:
uv run pytestruns the default set. - CI (GitHub Actions, later): lint, types and the default set on Linux; the
compositorset in a job with a headless sway;perfon demand. macOS and Windows are not v1 (V1 Scope). - Software drawing (
llvmpipe) is the reference for reference images, so a snapshot differs from a GPU render by a tolerance. Reference images are few and set per block, not per screen. #needs-verification
Conventions¶
- One behaviour per test; the name says what is expected.
- Every acceptance criterion in a spec is a test or a line in the manual checklist, tagged with the note it came from.
- A bug found by code is a test first, then the fix.
- No test needs the network or the user's real config;
--config-dirpoints at a temporary directory (IPC and CLI > The Command Line). - The
tess_dlcorpus is run as it ships; the shell adds cases byTDL-REQ-###totess-dl, not to its own copy (tess-dl First Slice).
Configuration¶
None.
Failure Modes and Recovery¶
| Problem | Handling |
|---|---|
| tre cannot create a window with no display | The tre tests skip with the error text; unit tests still run |
| Reference images differ across machines | Compare with a tolerance; regenerate only by a flag |
| A test depends on timing | Use Window.advance(ms), not sleeps |
| The vault copy for the table test is stale | The test reports the date of the copy and fails if the doc table has keys the code does not |
Open Questions¶
- M1 commits one reference PNG of the example at 400x32, compared with a tolerance (maintainer, 2026-11-04, D17).
- Which other blocks get reference images? Context: M1 has one reference PNG; more images cost review time when looks change. Recommendation: add one image per block when that block is built, with the same tolerance.
- Does the table-vs-docs test read the vault directly in the maintainer's environment, or a copy under
tests/data/that a script refreshes? Context: CI has no vault. Recommendation: the copy, so CI works. - Do we adopt tre's headless sway setup for the CI job? Context: the job is needed once the first
LayerWindowis built. Recommendation: adopt tre's setup at that point. - Do we set a coverage target? Context: a target early on rewards trivial tests. Recommendation: none at first; report coverage only.
Questions After Testing¶
- How does tre expose the accessibility tree to a test? Context: Accessibility checks need it. Recommendation: assert on the tree if tre exposes one, and otherwise check roles through the shell's own model. Answered by: a probe of tre's accessibility API.
Acceptance Criteria¶
-
uv run pytestruns the default set with no display. - A new binder table row without a matching Block Reference entry fails the table test, and the reverse.
- The import rules of Shell Package Layout are tested.
- The first Bar built at M1 has a test that reads its properties back from the tre nodes.
- Each milestone ends with its manual checklist written.