#!/usr/bin/env bash # lib/gitea/tests/wire-http.sh — end-to-end wire test over REAL HTTP. # # The in-process wire suite (tests/wire.sx) drives the client against # gitea/forge-app — a function call, no sockets. This script covers the # transport the suite can't: a served forge (kernel http-listen) and a # client whose remote is gitea/http-app (kernel http-request). This is # the path that carries clone/fetch/push between real machines — and # the gap that hid the fetch-pack "hang" (interpreted-parser slowness). # # Serves on 127.0.0.1:8943 with a throwaway persist dir, runs # wire-http-client.sx (ls-remote / clone / push branch / fresh-clone # verify / delete branch), then greps the results for failures. # # Usage: bash lib/gitea/tests/wire-http.sh # exit 0 = pass set -uo pipefail cd "$(git rev-parse --show-toplevel)" SX_SERVER="${SX_SERVER:-hosts/ocaml/_build/default/bin/sx_server.exe}" [ -x "$SX_SERVER" ] || SX_SERVER="/root/rose-ash/hosts/ocaml/_build/default/bin/sx_server.exe" if [ ! -x "$SX_SERVER" ]; then echo "ERROR: sx_server.exe not found." >&2 exit 1 fi PORT=8943 WORK=/tmp/sx-wire-http-test rm -rf "$WORK" mkdir -p "$WORK/persist" # ── serve a throwaway forge ────────────────────────────────────────── HOST_PORT=$PORT SX_INSTANCE=localhost SX_GITEA_ADMIN=giles \ SX_GITEA_TOKEN=wire-test-token SX_PERSIST_DIR="$WORK/persist" \ SX_HTTP_HOST=127.0.0.1 \ timeout 600 bash lib/gitea/serve.sh > "$WORK/server.log" 2>&1 & SERVER_PID=$! cleanup() { kill "$SERVER_PID" 2>/dev/null; } trap cleanup EXIT # wait for the ref advertisement to come up (server boots ~10s) for i in $(seq 1 60); do if curl -s -m 2 "http://127.0.0.1:$PORT/giles/welcome/info/refs" \ -H "Authorization: Bearer wire-test-token" | grep -q "heads/main"; then break fi sleep 2 done if ! curl -s -m 2 "http://127.0.0.1:$PORT/giles/welcome/info/refs" \ -H "Authorization: Bearer wire-test-token" | grep -q "heads/main"; then echo "FAIL: server did not come up on :$PORT" >&2 tail -5 "$WORK/server.log" | tr -d '\000' >&2 exit 1 fi # ── run the client ─────────────────────────────────────────────────── # wire client stack only (no web UI extras): kernel + parser + persist + # sx-git + datalog/acl + dream + gitea repo/access/web/wire + import. MODULES=( "spec/stdlib.sx" "spec/parser.sx" "lib/r7rs.sx" "lib/persist/event.sx" "lib/persist/backend.sx" "lib/persist/log.sx" "lib/persist/kv.sx" "lib/artdag/dag.sx" "lib/git/object.sx" "lib/git/ref.sx" "lib/git/dag.sx" "lib/git/worktree.sx" "lib/git/diff.sx" "lib/git/merge.sx" "lib/git/porcelain.sx" "lib/datalog/tokenizer.sx" "lib/datalog/parser.sx" "lib/datalog/unify.sx" "lib/datalog/db.sx" "lib/datalog/builtins.sx" "lib/datalog/aggregates.sx" "lib/datalog/strata.sx" "lib/datalog/eval.sx" "lib/datalog/api.sx" "lib/datalog/magic.sx" "lib/acl/schema.sx" "lib/acl/facts.sx" "lib/acl/engine.sx" "lib/dream/types.sx" "lib/dream/router.sx" "lib/dream/middleware.sx" "lib/dream/error.sx" "lib/dream/html.sx" "lib/dream/json.sx" "lib/dream/auth.sx" "lib/dream/api.sx" "lib/gitea/repo.sx" "lib/gitea/access.sx" "lib/gitea/web.sx" "lib/gitea/wire.sx" "lib/gitea/import.sx" "lib/gitea/tests/wire-http-client.sx" ) E=1 { for M in "${MODULES[@]}"; do echo "(epoch $E)"; echo "(load \"$M\")"; E=$((E+1)) done } | timeout 300 "$SX_SERVER" > "$WORK/client.log" 2>&1 # ── report ─────────────────────────────────────────────────────────── if [ ! -f "$WORK/results.txt" ]; then echo "FAIL: client produced no results (see $WORK/client.log)" >&2 tr -d '\000' < "$WORK/client.log" | tail -5 >&2 exit 1 fi cat "$WORK/results.txt" echo if grep -q "^ng " "$WORK/results.txt"; then echo "wire-http: FAIL" >&2 exit 1 fi TOTAL=$(grep -c "^ok " "$WORK/results.txt") echo "wire-http: PASS ($TOTAL checks)"