#!/bin/bash # Build the stream audit collector and run the kit's tests: the player integration's unit tests # against the corpus, then the end-to-end run in a real browser (e2e/audit.e2e.mjs). # # e2e/run.sh [--runs N] # # Environment: CARGO_TARGET_DIR, BROWSER_BIN (an installed browser; otherwise the automation # package's own, which PLAYWRIGHT_BROWSERS_PATH must then hold), AUDIT_E2E_OUT (where artifacts go), # NPM_OFFLINE (set: install the packages from the local cache alone). The packages come from # e2e/package-lock.json (`npm ci --ignore-scripts`: no install script runs). Nothing listens beyond # loopback. set -euo pipefail HERE=$(cd "$(dirname "$0")" && pwd) CRATE=$(cd "$HERE/.." && pwd) OUT=${AUDIT_E2E_OUT:-${TMPDIR:-/tmp}/wai-audit-e2e} TARGET=${CARGO_TARGET_DIR:-$CRATE/target} export CARGO_TARGET_DIR="$TARGET" mkdir -p "$OUT" echo "== the collector" (cd "$CRATE" && cargo build --locked --release) echo "== the packages" PKG="$OUT/pkg" mkdir -p "$PKG" cp "$HERE/package.json" "$HERE/package-lock.json" "$PKG/" (cd "$PKG" && npm ci --ignore-scripts --no-audit --no-fund ${NPM_OFFLINE:+--offline}) PLAYER="$PKG/node_modules/hls.js/dist/hls.min.js" # allow-name: the open-source web player's package and its script echo "== the player integration's unit tests" node --test "$CRATE/web/audit.test.mjs" echo "== end to end" browser=() [ -n "${BROWSER_BIN:-}" ] && browser=(--browser "$BROWSER_BIN") PLAYWRIGHT_HOST="$PKG/node_modules" node "$HERE/audit.e2e.mjs" \ --collector "$TARGET/release/wai-audit" --web "$CRATE/web" --page "$HERE/page" --player "$PLAYER" \ --out "$OUT/results" ${browser[@]+"${browser[@]}"} "$@"