#!/usr/bin/env bash # # Smoke test: launch the built binary and verify it actually serves the UI and # starts the backend. Fails loudly (non-zero) if a native module won't load or # the server never comes up - this is the main guard for the single-file build. # set -euo pipefail ROOT="$(cd "$(dirname "$0")/.." && pwd)" cd "$ROOT" BIN="${1:-dist/httptoolkit}" PORT="${PORT:-8099}" SERVER_PORT="${SERVER_PORT:-45457}" echo "==> --help must exit 0" "$BIN" --help echo "==> launching $BIN on port $PORT" "$BIN" --port "$PORT" --server-port "$SERVER_PORT" --no-open & PID=$! trap 'kill "$PID" 2>/dev/null || true' EXIT # Wait up to ~30s for the UI port to answer: ok=0 for _ in $(seq 1 60); do if curl -fsS "http://127.0.0.1:${PORT}/" -o /tmp/htk-index.html 2>/dev/null; then ok=1; break fi if ! kill -0 "$PID" 2>/dev/null; then echo "!! binary exited early"; exit 1 fi sleep 0.5 done [ "$ok" = 1 ] || { echo "!! UI never responded on :$PORT"; exit 1; } echo "==> UI responded; checking it looks like the HTK app" grep -qi 'httptoolkit\|