#!/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 # Each group's spec reporter ends with its own summary. Print one combined line so a reader (or an # agent) cannot mistake the parallel group's "N pass" for the suite total; it is the last line of # results/e2e.log too. Field names are matched from the end so the leading "ℹ" is irrelevant. summary_field() { # awk -v k="$1" 'NF >= 2 && $(NF-1) == k && $NF ~ /^[0-9]+$/ { v = $NF } END { print v + 0 }' "$2" } S_TESTS=$(summary_field tests run/logs/e2e-serial.log) S_PASS=$(summary_field pass run/logs/e2e-serial.log) S_FAIL=$(summary_field fail run/logs/e2e-serial.log) S_SKIP=$(summary_field skipped run/logs/e2e-serial.log) P_TESTS=$(summary_field tests run/logs/e2e-parallel.log) P_PASS=$(summary_field pass run/logs/e2e-parallel.log) P_FAIL=$(summary_field fail run/logs/e2e-parallel.log) P_SKIP=$(summary_field skipped run/logs/e2e-parallel.log) printf 'e2e total: tests %d / pass %d / fail %d / skip %d (serial %d, parallel %d)\n' \ "$((S_TESTS + P_TESTS))" "$((S_PASS + P_PASS))" "$((S_FAIL + P_FAIL))" \ "$((S_SKIP + P_SKIP))" "$S_TESTS" "$P_TESTS" | tee -a results/e2e.log [ "${rc:-0}" -eq 0 ] || exit "$rc"