Skip to main content

Module testing

Module testing 

Source
Expand description

PNG golden testing: tolerance-based image comparison with an update mode, used by every visual test in the workspace.

Comparison passes when every channel delta is at most 3/255 and fewer than 0.2 percent of pixels exceed that. FENESTRA_UPDATE_SNAPSHOTS=1 regenerates goldens. On failure three artifacts land next to the golden: <name>.actual.png (what rendered), <name>.diff.png (the offending pixels in red over the dimmed golden), and <name>.side.png (golden | actual | diff side by side) — read the diff first; it shows where, not just how much.

Goldens are rendered on macOS/Metal; a software rasterizer (CI’s lavapipe) antialiases slightly differently, so the pixel budget can be widened there with FENESTRA_SNAPSHOT_BUDGET (e.g. 0.006) without loosening the reference platform.

Enums§

FilmstripError
What can go wrong composing a filmstrip via filmstrip_image: never a panic, always one of these.

Constants§

BUDGET_ENV
Env var overriding the differing-pixel budget (a fraction, e.g. 0.006), for runners whose rasterizer differs from the goldens’.
MAX_STRIP_SCALE
See MIN_STRIP_SCALE.
MIN_STRIP_SCALE
Per-cell scale bounds (clamp_strip_scale): below the floor a frame is unreadably small; above 1.0 there is nothing to upscale — a filmstrip never carries more detail than the frames it tiles.
UPDATE_ENV
Env var that regenerates goldens instead of comparing.

Functions§

assert_filmstrip_snapshot
Composes frames captured by crate::Harness::film into one horizontal filmstrip and compares it against the PNG golden dir/name.png exactly like assert_png_snapshot (same env vars, same .actual/.diff/.side failure artifacts). See filmstrip_image for how the strip is composed.
assert_filmstrip_snapshot_scaled
Like assert_filmstrip_snapshot, with an explicit per-cell scale (clamped to 0.05..=1.0) so a strip of many, or large, frames still makes a small, reviewable golden.
assert_png_snapshot
Compares actual against the golden dir/name.png.
clamp_strip_scale
Clamps a filmstrip’s per-cell scale into the composable range (0.05..=1.0, see MIN_STRIP_SCALE/MAX_STRIP_SCALE); non-finite input clamps to the default (no shrink), same as a NaN or infinite input would from any other caller-supplied dimension in this crate.
filmstrip_image
Composes frames captured by crate::Harness::film into one horizontal filmstrip: each frame side by side, left to right, captioned with its index and elapsed time (index * interval_ms, matching the interval_ms passed to film). scale (per-cell, clamped via clamp_strip_scale) shrinks each thumbnail so a strip of many, or large, frames still composes to a reviewable size.