Skip to main content

Module snapshot

Module snapshot 

Source
Expand description

Golden snapshots: compare a ui.screenshot reply with a baseline PNG.

Baselines live in tests/snapshots/<name>.png (relative to the working directory, which is the package folder under cargo test; ASHLAR_SNAPSHOT_DIR overrides it) next to <name>.meta.json, which records what rendered them: {adapter, backend, scale, width, height, tolerance?}.

  • The comparison is exact unless a Tolerance is given, or recorded in the baseline’s meta.
  • On a mismatch, <name>-new.png (what was rendered) and <name>-diff.png (the new picture with every differing pixel magenta) are written next to the baseline, and the check fails.
  • ASHLAR_UPDATE_SNAPSHOTS=1 writes the baseline instead of comparing.
  • A baseline rendered on another adapter or backend, or a screenshot with no GPU renderer (grey), is skipped with a note, not failed: pixels from different GPUs differ.

Egui’s own test harness has a snapshot feature, but it is built on its own renderer, compares perceptually, takes no adapter metadata, and pulls the UI toolkit into this rank-4 crate; this module is small and works on any ui.screenshot reply, from a live app or a Driver.

Structs§

Snapshots
Where baselines live and how they are checked.
Tolerance
How far a screenshot may drift from its baseline and still match.

Enums§

Outcome
What a snapshot check did.