test: build/locate backend binary + override origin in verify script
This commit is contained in:
@@ -88,10 +88,23 @@ fi
|
|||||||
rm -rf "$SYN"
|
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
|
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"
|
# `cargo test` only builds the test harness, not the standalone binary. Prefer the
|
||||||
[[ -x "$BIN" ]] || bad "backend binary missing at $BIN"
|
# 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) =="
|
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" \
|
VEHICLE_TRANSLATIONS_JSON="$WD/vt.json" VEHICLE_DATA_CACHE_JSON="$WD/vc.json" \
|
||||||
BACKEND_PORT="$BE_PORT" "$BIN" >/tmp/vgd_be.log 2>&1 &
|
BACKEND_PORT="$BE_PORT" "$BIN" >/tmp/vgd_be.log 2>&1 &
|
||||||
BE_PID=$!
|
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" \
|
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=$!
|
WEB_PID=$!
|
||||||
# wait for both to listen
|
# wait for both to listen
|
||||||
for _ in $(seq 1 20); do
|
for _ in $(seq 1 20); do
|
||||||
|
|||||||
Reference in New Issue
Block a user