#!/bin/bash # Headless UI workflow self-test. # # Builds alkane-toolkit, then runs it in ALKANE_SELFTEST mode under a private # Xvfb display. In that mode the app loads the bench-fleet fixtures (the # expected hardware output), renders them through the real wxWidgets table and # KPI header, reads back what the widgets actually display, and compares to the # expected result. It prints one line per check and exits non-zero on any # mismatch -- so this is a CI-able, hardware-free check that the app's functions # produce the intended output. # # Usage: scripts/ui-selftest.sh [binary] # binary defaults to the release build in the cargo target dir. set -u REPO=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) WX_PREFIX="${WX_PREFIX:-$HOME/.cache/wx-3.3.3-linux}" export WX_RS_WXCONFIG="${WX_RS_WXCONFIG:-$WX_PREFIX/bin/wx-config}" BIN="${1:-}" if [ -z "$BIN" ]; then if [ ! -x "$WX_PREFIX/bin/wx-config" ]; then "$REPO/scripts/build-wx-linux.sh"; fi ( cd "$REPO" && cargo build --release -p alkane-gui --offline ) || exit 3 # locate the binary via the machine-local target dir TDIR=$(cd "$REPO" && cargo metadata --no-deps --format-version 1 --offline 2>/dev/null \ | tr ',' '\n' | grep -o '"target_directory":"[^"]*"' | head -1 | cut -d'"' -f4) [ -n "$TDIR" ] || TDIR="$REPO/target" BIN="$TDIR/release/alkane-toolkit" fi [ -x "$BIN" ] || { echo "binary not found: $BIN" >&2; exit 3; } DISP=":98" Xvfb "$DISP" -screen 0 1280x850x24 -nolisten tcp >/dev/null 2>&1 & XPID=$! sleep 1.2 DISPLAY="$DISP" GDK_BACKEND=x11 ALKANE_SELFTEST=1 "$BIN" RC=$? kill "$XPID" 2>/dev/null echo "== ui-selftest exit=$RC ==" exit "$RC"