pcbjam/scripts/compare-screenshots.sh
Viktor Vaczi 7dc1bf27e0 refactor: collapse dual-mode plumbing — the DOM port is the only WASM build
The canvas (wxUniversal) mode is gone (wxwidgets submodule); remove every
piece of side-by-side plumbing so there is exactly one build and one test
flow:

- scripts/build-wxuniversal-wasm.sh -> scripts/build-wx-wasm.sh; no
  --dom/--enable-universal; builds into build-wasm/wxwidgets
- build-wasm-test.sh: no DOM_BUILD / apps-dom rsync mirror / PORT=dom;
  apps build straight into tests/apps (Makefile.wasm PORT conditionals
  collapsed; wx.js + wx-dom.js always pre-js)
- docker/build.sh, build-kicad-target.sh, env.sh: WX_PORT / -dom /
  -universal suffixes removed; kicad builds to kicad-<app>, outputs to
  output/; wx.js/wx-dom.js copied from the real source path
  (/workspace/wxwidgets/build/wasm — the old build-wasm path never
  existed and silently failed)
- setup-kicad-wasm.sh: single target dir; the perl wx-dom.js injection is
  gone — the 7 checked-in kicad pages now reference wx-dom.js directly
- playwright configs serve apps/; fixtures drop the test-results/dom and
  logs/wxwidgets/dom namespacing; boot.spec asserts wxDomPort
  unconditionally; pcbnew.spec uses one reference image;
  appearance.spec assertions unconditional
- compare/update-baseline-screenshots.sh: --port removed
- tests/gal-regression/wasm/Makefile: links build-wasm/wxwidgets and
  carries wx-dom.js as a second pre-js — the gal-webgl suite (30 specs)
  now actually builds and runs here (it needed host-side boost+glm via
  scripts/deps; the bundle had been missing, timing the whole spec out)
- tests: clickCanvas() dispatches via page.mouse (DOM widgets
  legitimately cover the canvas; locator actionability refused the
  click); the comprehensive spec drives wxChoice through its native
  <select> (browser-owned popup cannot be coordinate-clicked)
- docs: README/CLAUDE.md/build.md script names and dirs;
  features/wx-dom-port README reframed (DOM is THE port), visual-notes
  bugs 26-28; FindwxWidgets.cmake config label drops 'wasmuniv'
- wxwidgets submodule -> 9dbacc9448 (DOM-only port, fork diff shrunk)

Gate: full wx e2e suite 292 passed / 1 skipped / 0 failed — first run
ever with the gal-webgl specs green (28 scenarios + load + sequential).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 20:19:48 +02:00

108 lines
3.1 KiB
Shell
Executable file

#!/bin/bash
# Compare test screenshots with baseline screenshots
# This script compares all PNG files in baseline-screenshots with test-results
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(dirname "$SCRIPT_DIR")"
BASELINE_DIR="$PROJECT_ROOT/tests/baseline-screenshots"
TEST_RESULTS_DIR="$PROJECT_ROOT/tests/test-results"
# Check if directories exist
if [ ! -d "$BASELINE_DIR" ]; then
echo "ERROR: Baseline directory not found: $BASELINE_DIR"
exit 1
fi
if [ ! -d "$TEST_RESULTS_DIR" ]; then
echo "ERROR: Test results directory not found: $TEST_RESULTS_DIR"
exit 1
fi
echo "=== Screenshot Comparison ==="
echo "Baseline: $BASELINE_DIR"
echo "Test Results: $TEST_RESULTS_DIR"
echo ""
# Counters
total=0
identical=0
different=0
missing_current=0
extra_current=0
# Compare all baseline screenshots
echo "=== Comparing Baseline Screenshots ==="
for baseline in "$BASELINE_DIR"/*.png; do
filename=$(basename "$baseline")
current="$TEST_RESULTS_DIR/$filename"
total=$((total + 1))
if [ ! -f "$current" ]; then
echo "MISSING: $filename (not in test results)"
missing_current=$((missing_current + 1))
continue
fi
# Compare using cmp (byte-by-byte comparison)
if cmp -s "$baseline" "$current"; then
identical=$((identical + 1))
# Only show identical files if verbose
if [ "$1" = "-v" ] || [ "$1" = "--verbose" ]; then
echo "IDENTICAL: $filename"
fi
else
different=$((different + 1))
# Get file sizes
baseline_size=$(stat -f%z "$baseline" 2>/dev/null || stat -c%s "$baseline")
current_size=$(stat -f%z "$current" 2>/dev/null || stat -c%s "$current")
diff_bytes=$((current_size - baseline_size))
# Calculate percent difference
if [ "$baseline_size" -gt 0 ]; then
diff_pct=$(echo "scale=2; ($diff_bytes * 100) / $baseline_size" | bc)
else
diff_pct="N/A"
fi
echo "DIFFERENT: $filename (baseline: ${baseline_size}B, current: ${current_size}B, diff: ${diff_bytes}B / ${diff_pct}%)"
fi
done
# Check for extra files in test results not in baseline
echo ""
echo "=== Checking for Extra Screenshots ==="
for current in "$TEST_RESULTS_DIR"/*.png; do
filename=$(basename "$current")
baseline="$BASELINE_DIR/$filename"
if [ ! -f "$baseline" ]; then
extra_current=$((extra_current + 1))
current_size=$(stat -f%z "$current" 2>/dev/null || stat -c%s "$current")
echo "EXTRA: $filename (${current_size}B, not in baseline)"
fi
done
# Summary
echo ""
echo "=== Summary ==="
echo "Total baseline screenshots: $total"
echo "Identical: $identical"
echo "Different: $different"
echo "Missing from test results: $missing_current"
echo "Extra in test results: $extra_current"
# Exit with error if there are differences
if [ "$different" -gt 0 ] || [ "$missing_current" -gt 0 ]; then
echo ""
echo "WARNING: There are differences between baseline and test results!"
exit 1
else
echo ""
echo "SUCCESS: All screenshots match baseline!"
exit 0
fi