From 616139d6ce2be49b5aca93502ab35f2f527e1f63 Mon Sep 17 00:00:00 2001 From: FURRO404 Date: Thu, 18 Jun 2026 01:09:06 -0700 Subject: [PATCH] test: build/locate backend binary + override origin in verify script --- scripts/verify_game_detail.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/scripts/verify_game_detail.sh b/scripts/verify_game_detail.sh index 81c7bb3..d6a1f34 100755 --- a/scripts/verify_game_detail.sh +++ b/scripts/verify_game_detail.sh @@ -88,10 +88,23 @@ fi rm -rf "$SYN" # --------------------------------------------------------------------------- -echo "== 3. cargo tests + build ==" +echo "== 3. cargo tests + binary ==" if cargo test --manifest-path "$WEB_REPO/backend/Cargo.toml" >/tmp/vgd_cargo.log 2>&1; then ok "cargo test"; else bad "cargo test (see /tmp/vgd_cargo.log)"; fi -BIN="$WEB_REPO/backend/target/debug/tssbot-backend" -[[ -x "$BIN" ]] || bad "backend binary missing at $BIN" +# `cargo test` only builds the test harness, not the standalone binary. Prefer the +# release binary (built at deploy); otherwise build a debug one. +BIN="" +if [[ -x "$WEB_REPO/backend/target/release/tssbot-backend" ]]; then + BIN="$WEB_REPO/backend/target/release/tssbot-backend" + ok "using release binary" +else + if cargo build --manifest-path "$WEB_REPO/backend/Cargo.toml" >/tmp/vgd_build.log 2>&1; then + BIN="$WEB_REPO/backend/target/debug/tssbot-backend" + ok "built debug binary" + else + bad "cargo build (see /tmp/vgd_build.log)" + fi +fi +[[ -n "$BIN" && -x "$BIN" ]] || bad "backend binary unavailable" # --------------------------------------------------------------------------- echo "== 4. Build fixture (multi-vehicle player to catch the double-count bug) ==" @@ -135,8 +148,12 @@ TSS_BATTLES_DB="$WD/tss_battles.db" TSS_TEAMS_DB="$WD/tss_teams.db" \ VEHICLE_TRANSLATIONS_JSON="$WD/vt.json" VEHICLE_DATA_CACHE_JSON="$WD/vc.json" \ BACKEND_PORT="$BE_PORT" "$BIN" >/tmp/vgd_be.log 2>&1 & BE_PID=$! +# Override PUBLIC_ORIGIN/comingsoon so the server's same-origin guard accepts the +# localhost test origin and serves normally. server.cjs's loadEnvFile only fills +# unset/empty vars, so these non-empty values win over the prod .env. PORT="$WEB_PORT" API_UPSTREAM="http://127.0.0.1:$BE_PORT" VEHICLE_ICONS_DIR="$ICONS" \ - UPTIME_STORAGE_DIR="$STORE" node "$WEB_REPO/server.cjs" >/tmp/vgd_web.log 2>&1 & + UPTIME_STORAGE_DIR="$STORE" PUBLIC_ORIGIN="http://localhost:$WEB_PORT" comingsoon="FALSE" \ + node "$WEB_REPO/server.cjs" >/tmp/vgd_web.log 2>&1 & WEB_PID=$! # wait for both to listen for _ in $(seq 1 20); do