# Tests — rgui / ttgui Zero-dependency suite. The test framework is [`../tttest.hpp`](../tttest.hpp) (header-only, C++ standard library only — no Catch2/GoogleTest/doctest). The framework under test is [`../ttgui.hpp`](../ttgui.hpp). ## Build and run ```sh # Default suite (tiers 1–3: unit, integration, golden) — headless, no TTY needed make tests # or: g++ -std=c++20 -Wall -Wextra -Wpedantic -O2 tests/test_*.cpp -o run_tests ./run_tests # Sanitizer build (tiers 1–3) g++ -std=c++20 -g -fsanitize=address,undefined tests/test_*.cpp -o run_tests_asan ./run_tests_asan # Demo (its --selftest executes this same suite — one suite, not two) g++ -std=c++20 -Wall -Wextra -Wpedantic -O2 demo.cpp -o demo ./demo --selftest # exits 2 with instructions if ./run_tests is not built yet ./demo --dump-config ``` ## Runner options `./run_tests [--list] [--filter ] [--tags [a][b]] [--exclude-tags [x]] [--repeat N] [--shuffle --seed S] [--fail-fast] [--timeout ] [--reporter console|tap|json] [--update-golden] [--golden-dir ]` Exit code: 0 = all pass, 1 = failures, 2 = runner/usage error. `SKIP` (with a reason) is printed only for genuinely unavailable platform facilities (the `[pty]` tier) and is never counted as a pass. ## Tiers | Tier | Contents | Command | Expected runtime | |---|---|---|---| | 1 Unit | geometry, JSON, config, parsers, widget state | `./run_tests --exclude-tags [pty][fuzz][golden]` | seconds | | 2 Integration | events/focus, window manager, drag & drop, layout+render, XFCE demo scenarios | `./run_tests --tags [integration]` or default run | seconds | | 3 Golden | checked-in screens in `tests/golden/` | `./run_tests --tags [golden]` | seconds | | 4 PTY + TTY smoke | real `/bin/sh` PTYs; demo under a PTY harness | `./run_tests --tags [pty]` | seconds–tens of seconds | | 5 Sanitizer | tiers 1–3 under ASan/UBSan | `./run_tests_asan` | under a minute | | 6 Fuzz | seeded resize/event/VT/JSON fuzz, watchdog-bounded | `./run_tests --tags [fuzz]` | small default budget | Golden files are regenerated only intentionally: `./run_tests --update-golden`. A normal run never writes them; a golden diff is a behaviour/appearance change. ## Traceability (prompt.md § → tests) | prompt.md requirement | Test file(s) / cases | |---|---| | §1 zero dependencies, warning-free build | build commands above; `grep -R "curses\|catch2\|gtest" ttgui.hpp tttest.hpp tests/` must be empty | | §2 semantic window colours | `test_golden.cpp` "one window of each semantic colour"; `test_config.cpp` window-colour cases | | §2 caption/close/shade/sticky/resize, bevels | `test_window_manager.cpp`, `test_canvas.cpp`, `test_golden.cpp` "bevel/inset cells" | | §3 OOP architecture, widget tree invariants | `test_canvas.cpp`, `test_layout.cpp`, invariants in `test_window_manager.cpp` / `test_events.cpp` | | §4 every widget | `test_widgets_buttons.cpp`, `test_widgets_text.cpp`, `test_widgets_lists.cpp`, `test_widgets_panels.cpp` (one family per file; Gallery iteration in `test_xfce_demo.cpp`) | | §5 windows: drag/resize/snap/shade/sticky/maximize/workspaces | `test_window_manager.cpp` | | §6 events, focus, hotkeys | `test_events.cpp`, `test_focus.cpp` | | §6 drag & drop | `test_dragdrop.cpp` | | §7 terminal widget, VT parser, PTY | `test_terminal_vt.cpp`, `test_pty.cpp` (`[pty][slow]`) | | §8 effects, terminal bell | `test_effects.cpp`, `test_bell.cpp` | | M6 widget base colours from Config (review.md) | `test_uicolors.cpp` | | Double terminal input regression (review.md C2) | `test_terminal_input_once.cpp` | | §9 Config single source of truth, `*.env.json` | `test_config.cpp`, `test_json.cpp`, `test_config_ui.cpp`; `./demo --dump-config` round-trip | | §10 XFCE panel/wm/desktop/session/apps | `test_xfce_demo.cpp`, `test_demo_smoke.cpp` | | §11 demo boot state, Gallery, console | `test_xfce_demo.cpp`, `test_demo_smoke.cpp`, `test_golden.cpp` "panel + desktop boot screen" | | §12 acceptance checklist | this table + full default run + sanitizer tier | | §13.1 test framework itself | `test_tttest.cpp` | | §13.4 golden screens | `test_golden.cpp`, `tests/golden/*.cells.txt` (full-cell glyph+colour+attrs) | | Stage D test honesty | `test_staged.cpp` (InputScript real dispatch, modal blocking, effects via real paths, drag threshold/highlight, maximized resize, bell 100ms boundary, config search-order), `test_tttest.cpp` registry-sandbox/full-cell cases | | Stage C demo completions | `test_stagec.cpp` (config surface, bell fake clock, MiniMap filters, OSK, wordWrap, close veto, wide glyph, capture) | | §13.5 invariants | asserted in `test_window_manager.cpp`, `test_events.cpp`, `test_terminal_vt.cpp` | ## Rules - Never delete, skip, or soften a failing case to get green. Fix the framework, or change the expectation with the reason recorded. - When you add a widget, app, or behaviour, add its case in the same change and extend the traceability table above. - Tests are hermetic: fake clock, seeded RNG, virtual terminal, temp sandbox dirs. No TTY, no `$HOME`, no network, no real `$SHELL` (`/bin/sh` only). ## Stage regression files `test_stageb.cpp` (framework review fixes), `test_stagec.cpp` (demo/spec completions), `test_staged.cpp` (InputScript/modal/drag/config-search-order), `test_terminal_input_once.cpp` (double-input), and `test_uicolors.cpp` (configurable widget colours) map to the findings in `../review.md`; each review finding names its test there.