Files
windroost/p2_godot_sample/run_longrun_stability_test.sh
T
wushenghua 66b6cf2926 refactor: unify upgrade cost + long-run stability gate (PRODUCTION/49 goal)
Wrote PRODUCTION/49 as the authoritative ongoing-optimization goal after
analyzing what remains. Executed all owner-independent items:

A1 upgrade cost single source of truth: game_root hardcoded 120*1.15^(lvl-1)
in two places while battle HUD read mvp_battle_rules.json — a balance change
would desync displayed cost from the actual debit. All three call sites now use
ProfileStore.upgrade_cost(level) (rules-driven). upgrade_cost_test proves the
helper matches an independent formula at Lv1/5/12, the skyport card shows the
authoritative cost, and the real debit equals it (210 at Lv5). 5 stages pass.

A2 long-run stability gate: new longrun_stability_test drives 400 frames of a
real battle with continuous damage/VFX and asserts floating numbers <=16,
roster cards constant (3), pop tweens <=4, visible units <=5, and no growth
from warmup to frame 400. This guards the leak classes fixed earlier.

A4 evidence audit updated (PRODUCTION/48 sections 4b/4c) with all fixes and
the one honest design-open item (ultimate energy recharge has no authoritative
sim contract, so not invented).

Both tests registered in run_p2_checks.sh. Full gate P2_CHECKS_PASS, log audit
clean, 0 script/lambda errors. prototype/ untracked.
2026-11-18 05:09:32 +08:00

29 lines
968 B
Bash
Executable File

#!/bin/zsh
set -euo pipefail
ROOT_DIR="${0:A:h}"
source "${0:A:h}/_test_env.sh"
GODOT_BIN="${GODOT_BIN:-/Applications/Godot.app/Contents/MacOS/Godot}"
LOG_PATH="$ROOT_DIR/artifacts/longrun_stability_test.log"
TIMEOUT_SECONDS="${LONGRUN_TIMEOUT_SECONDS:-180}"
if [[ ! -x "$GODOT_BIN" ]]; then print -u2 "Godot not found"; exit 127; fi
mkdir -p "$ROOT_DIR/artifacts"
"$GODOT_BIN" --headless --path "$ROOT_DIR" --script res://scripts/longrun_stability_test.gd > "$LOG_PATH" 2>&1 &
GODOT_PID=$!
(
sleep "$TIMEOUT_SECONDS"
kill -TERM "$GODOT_PID" 2>/dev/null || true
sleep 5
kill -KILL "$GODOT_PID" 2>/dev/null || true
) &
WATCHDOG_PID=$!
set +e
wait "$GODOT_PID"
STATUS=$?
set -e
kill -TERM "$WATCHDOG_PID" 2>/dev/null || true
wait "$WATCHDOG_PID" 2>/dev/null || true
cat "$LOG_PATH"
if [[ $STATUS -ne 0 ]]; then print -u2 "LONGRUN_FAIL exit=$STATUS"; exit "$STATUS"; fi
grep -q "LONGRUN_PASS" "$LOG_PATH" || { print -u2 "LONGRUN_FAIL no marker"; exit 4; }
exit 0