fix: enforce village resource invariants
This commit is contained in:
Regular → Executable
+19
-9
@@ -91,6 +91,7 @@ if [[ -z "$GODOT" ]]; then
|
||||
echo "ERROR: Godot binary not found. Set GODOT_BIN or add godot/godot4 to PATH."
|
||||
exit 1
|
||||
fi
|
||||
GODOT_ENV=(env "HOME=$GODOT_PROFILE" "APPDATA=$GODOT_PROFILE" "LOCALAPPDATA=$GODOT_PROFILE")
|
||||
|
||||
# -- 1. gdformat --------------------------------------------------------------
|
||||
fmt_tool=$(find_gdformat) || true
|
||||
@@ -177,7 +178,7 @@ fi
|
||||
godot_result="PASS"
|
||||
: > "$LOG/godot-check.log"
|
||||
if need_timeout; then
|
||||
if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" timeout 30 "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
|
||||
if timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
|
||||
godot_result="PASS"
|
||||
else
|
||||
ec=$?
|
||||
@@ -189,12 +190,15 @@ if need_timeout; then
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
|
||||
if "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
|
||||
godot_result="PASS"
|
||||
else
|
||||
godot_result="FAIL"
|
||||
fi
|
||||
fi
|
||||
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/godot-check.log"; then
|
||||
godot_result="FAIL"
|
||||
fi
|
||||
if [[ "$godot_result" == "FAIL" ]]; then
|
||||
grep -iE "error|warning|parse|syntax" "$LOG/godot-check.log" 2>/dev/null | head -20 | while IFS= read -r errline; do
|
||||
ERRORS+=("godot: $errline")
|
||||
@@ -208,15 +212,19 @@ scenario_result="PASS"
|
||||
for test in tests/*_test.gd; do
|
||||
echo "[RUN] $(basename "$test")" >> "$LOG/scenarios.log"
|
||||
if need_timeout; then
|
||||
if ! APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" timeout 30 "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
if ! timeout 30 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
scenario_result="FAIL"
|
||||
ERRORS+=("scenario: $(basename "$test") failed or timed out")
|
||||
fi
|
||||
elif ! APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
elif ! "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
scenario_result="FAIL"
|
||||
ERRORS+=("scenario: $(basename "$test") failed")
|
||||
fi
|
||||
done
|
||||
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/scenarios.log"; then
|
||||
scenario_result="FAIL"
|
||||
ERRORS+=("scenario: Godot reported a script load or parse error")
|
||||
fi
|
||||
if [[ "$scenario_result" == "FAIL" ]]; then
|
||||
FIXES+=("Fix failing project scenario tests")
|
||||
fi
|
||||
@@ -225,7 +233,7 @@ fi
|
||||
gut_result="SKIPPED"
|
||||
: > "$LOG/gut.log"
|
||||
if [[ -f "addons/gut/gut_cmdln.gd" ]]; then
|
||||
if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then
|
||||
if "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then
|
||||
gut_result="PASS"
|
||||
else
|
||||
gut_result="FAIL"
|
||||
@@ -254,8 +262,9 @@ echo " godot-check $godot_result"
|
||||
echo " scenarios $scenario_result"
|
||||
echo " gut $gut_result"
|
||||
|
||||
seen_err=()
|
||||
for e in "${ERRORS[@]}"; do
|
||||
seen_err=("__quality_sentinel__")
|
||||
for e in "${ERRORS[@]:-}"; do
|
||||
[[ -z "$e" ]] && continue
|
||||
contains_element "$e" "${seen_err[@]}" && continue
|
||||
seen_err+=("$e")
|
||||
echo " $e"
|
||||
@@ -264,9 +273,10 @@ done
|
||||
if $OVERALL && [[ ${#FIXES[@]} -gt 0 ]]; then
|
||||
echo ""
|
||||
echo " NEXT FIX:"
|
||||
seen_fix=()
|
||||
seen_fix=("__quality_sentinel__")
|
||||
idx=1
|
||||
for fix in "${FIXES[@]}"; do
|
||||
for fix in "${FIXES[@]:-}"; do
|
||||
[[ -z "$fix" ]] && continue
|
||||
contains_element "$fix" "${seen_fix[@]}" && continue
|
||||
seen_fix+=("$fix")
|
||||
echo " $idx. $fix"
|
||||
|
||||
Reference in New Issue
Block a user