One command rebuilds every examples Widget.cpp, re-renders it under
Xvfb, and diffs the screenshot against its golden with ImageMagick
RMSE (0.5 pct threshold):
tools/visreg/run.sh (also: make visreg)
Reuses the cdoc docs sweep render path (same g++ flags, same
Widget - XFrame demo window capture with the root-capture fallback).
Goldens vendored from /opt/lightgui-docs/shots (Dec 2, 2026). Report goes
to tools/visreg/report/report.txt (plus report.tsv and shots/); exit code
is 0 only when every gated widget passes.
Two deliberate behaviours, both documented in tools/visreg/README.md:
- failed shots are retried 3x (transient XOpenDisplay flakes; the docs
sweep needed a retry pass for the same four widgets)
- TTimeEdit, TDateEdit and TCalendar render the wall clock, so they are
reported SKIP (RMSE recorded, not gated) instead of FAIL
Baseline full run (Dec 2, 2026, HEAD beec92b): 544 PASS, 3 SKIP, 0 FAIL;
max RMSE among PASS 0.0000 pct (every passing widget pixel-identical).
Visual regression harness (C widgets)
One command, from the repo root:
tools/visreg/run.sh # full run: build + shoot + diff + report
make visreg # same thing via the Makefile
What it does
- Build — compiles every
examples/<Widget>.cpp(547) with the same flags the cdoc docs sweep used (g++ -std=c++17 -O2 -I widgets/components -I widgets <src> -lX11), 8 parallel workers, intotools/visreg/build/. - Shoot — runs each binary under Xvfb
:97, waits for the<Widget> - XFrame demowindow, screenshots it with ImageMagickimport(with the docs sweep's root-capture fallback when a per-window capture comes back black), intotools/visreg/report/shots/. - Diff — compares each new screenshot against its golden in
tools/visreg/golden/withcompare -metric RMSEand reports the normalised RMSE as a diff percentage. - Report — writes
tools/visreg/report/report.txt(per-widget PASS/FAIL + summary counts) andreport.tsv(machine-readable). Exit code is 0 only when every widget PASSes.
Retries and time-dependent widgets
Shooting is flaky at the edges: a binary occasionally exits before its
window appears (XOpenDisplay failing transiently — the docs sweep hit
the same flakes and needed a retry pass). A failed shot is retried up to
3 times before it counts as a failure.
Three widgets render the wall clock, so no golden can match them except when run in the same minute/day the golden was shot: TTimeEdit (defaults to the current time — two shots 65 s apart differ by 1.23% RMSE), TDateEdit and TCalendar (both default to today's date). They are still shot and diffed and their RMSE is recorded, but the result is SKIP (not gated) rather than FAIL, so a clean tree exits 0. A gross regression in one still shows up as a large RMSE in its SKIP row.
Threshold
A widget PASSes when its RMSE is at most 0.5%. Screenshots differ by
a few pixels run to run from font rendering / anti-aliasing, so exact
matching would false-positive on a clean tree; 0.5% was tuned so a clean
tree passes with headroom — the Dec 2, 2026 baseline run's worst PASS
was 0.0000% (every passing widget pixel-identical to its golden; see the
max-PASS line in report.txt) — while any visible draw change scores far
above it. Override per run:
tools/visreg/run.sh --threshold 0.2
Goldens
golden/ holds the 547 golden screenshots produced by the docs sweep
(/opt/lightgui-docs/shots/, Dec 2, 2026, repo HEAD 93d0fe9). They are
vendored here so the harness is self-contained. To diff against a
different golden set instead (e.g. a fresh baseline after an intentional
visual change), pass --golden DIR or set VISREG_GOLDEN_DIR.
To re-baseline after an intentional visual change, copy the new shots over the goldens and commit them together with the change:
cp tools/visreg/report/shots/*.png tools/visreg/golden/
Partial runs (no re-render needed to re-tune the threshold)
python3 tools/visreg/visreg.py --only diff --threshold 0.2 # re-diff saved shots
python3 tools/visreg/visreg.py --only build # rebuild only
python3 tools/visreg/visreg.py --only shoot # re-shoot only
VISREG_DISPLAY overrides the X display (default :97).
Notes
build/andreport/are generated and git-ignored; only the harness code, this README, andgolden/are committed.- Shooting is sequential (one X server, one window at a time); a full run takes roughly 10 minutes, most of it the 0.5 s settle per widget.
- A size mismatch between a new shot and its golden is a FAIL (the RMSE is still reported, computed after resizing, so the number stays useful).