#!/usr/bin/env bash # devbox run e2e: the headless-browser gate (TESTING 10.3). Builds the real client, then runs the # browser suite against the real server through the TLS/HTTP2 test nginx. Separate from # `devbox run test` so the fast server gate stays fast (TESTING 11.1); the client's own unit tests # are `devbox run client-test`. # # Parallelism: every test gets its own stack (state dir, free ports, nginx, server) and its own # browser, so test files run FFF_E2E_JOBS at a time (default: half the cores, capped at 4; # FFF_TEST_JOBS/FFF_E2E_JOBS=1 serialises). The files whose assertions are timing gates (the # tile-fill budget, the fog costs, the perf overlay) run alone first, unloaded, then the rest fan # out. The client dist and the server binaries are built once, before any worker starts. set -euo pipefail cd "$(dirname "$0")/../.." || exit 1 . tools/jobs.sh mkdir -p results run/logs fff_setup_tmpdir JOBS=$(fff_e2e_jobs) export CHROMIUM="${CHROMIUM:-$(command -v chromium || true)}" if [ -z "$CHROMIUM" ]; then echo "e2e: chromium not found; it is a root devbox package (devbox.json) - run inside devbox" >&2 exit 1 fi # npm deps stay out of tools/ (TESTING 10.4) and out of git; install once per checkout. ( cd client && { [ -d node_modules ] || npm ci --no-audit --no-fund; } ) ( cd client && npm run build ) # Shared Nim build cache: the server binaries the stacks launch (and the leak checker) are built # once here, not once per test file. node tools/prebuild.mjs server-only > run/logs/prebuild-e2e.log 2>&1 E2E_SERIAL=(client/e2e/map.test.mjs client/e2e/fog.test.mjs client/e2e/fogbench.test.mjs client/e2e/perf.test.mjs) E2E_PARALLEL=() for f in client/e2e/*.test.mjs; do case " ${E2E_SERIAL[*]} " in *" $f "*) ;; *) E2E_PARALLEL+=("$f") ;; esac done node --test --test-concurrency=1 --test-reporter=spec "${E2E_SERIAL[@]}" \ > run/logs/e2e-serial.log 2>&1 || rc=$? node --test --test-concurrency="$JOBS" --test-reporter=spec "${E2E_PARALLEL[@]}" \ > run/logs/e2e-parallel.log 2>&1 || rc=$? cat run/logs/e2e-serial.log run/logs/e2e-parallel.log > results/e2e.log cat results/e2e.log [ "${rc:-0}" -eq 0 ] || exit "$rc"