fix: stabilize godot 4.7 headless validation
This commit is contained in:
+35
-2
@@ -9,6 +9,8 @@ Set-Location $ROOT
|
||||
|
||||
$LOG = "logs/quality/latest"
|
||||
New-Item -ItemType Directory -Path $LOG -Force | Out-Null
|
||||
$GODOT_PROFILE = Join-Path $ROOT "logs/quality/godot_profile"
|
||||
New-Item -ItemType Directory -Path $GODOT_PROFILE -Force | Out-Null
|
||||
|
||||
$OVERALL = $false
|
||||
$ERRORS = @()
|
||||
@@ -16,8 +18,30 @@ $FIXES = @()
|
||||
$OWNED_GDSCRIPT_ROOTS = @("player", "simulation", "tests", "tools", "world")
|
||||
|
||||
# -- tool detection -----------------------------------------------------------
|
||||
function ConvertTo-ConsoleGodotPath($Path) {
|
||||
if (-not $Path) { return $null }
|
||||
$normalized = $Path.Replace('/', '\').Trim('"')
|
||||
if ($normalized.EndsWith(".exe")) {
|
||||
$consolePath = $normalized -replace '\.exe$', '_console.exe'
|
||||
if (Test-Path $consolePath) { return $consolePath }
|
||||
}
|
||||
if (Test-Path $normalized) { return $normalized }
|
||||
return $null
|
||||
}
|
||||
|
||||
function Find-ProjectGodot {
|
||||
$metadata = Join-Path $ROOT ".godot/editor/project_metadata.cfg"
|
||||
if (-not (Test-Path $metadata)) { return $null }
|
||||
$line = Select-String -Path $metadata -Pattern '^executable_path=' | Select-Object -First 1
|
||||
if (-not $line) { return $null }
|
||||
$rawPath = ($line.Line -replace '^executable_path=', '').Trim().Trim('"')
|
||||
return ConvertTo-ConsoleGodotPath $rawPath
|
||||
}
|
||||
|
||||
function Find-Godot {
|
||||
if ($env:GODOT_BIN) { return $env:GODOT_BIN }
|
||||
if ($env:GODOT_BIN) { return (ConvertTo-ConsoleGodotPath $env:GODOT_BIN) }
|
||||
$projectGodot = Find-ProjectGodot
|
||||
if ($projectGodot) { return $projectGodot }
|
||||
try { return (Get-Command godot -ErrorAction Stop).Source } catch {}
|
||||
try { return (Get-Command godot4 -ErrorAction Stop).Source } catch {}
|
||||
$common = @(
|
||||
@@ -99,7 +123,16 @@ function Invoke-GodotWithTimeout {
|
||||
$psi.RedirectStandardError = $true
|
||||
$psi.UseShellExecute = $false
|
||||
$psi.CreateNoWindow = $true
|
||||
$p = [Diagnostics.Process]::Start($psi)
|
||||
$previousAppData = $env:APPDATA
|
||||
$previousLocalAppData = $env:LOCALAPPDATA
|
||||
$env:APPDATA = $GODOT_PROFILE
|
||||
$env:LOCALAPPDATA = $GODOT_PROFILE
|
||||
try {
|
||||
$p = [Diagnostics.Process]::Start($psi)
|
||||
} finally {
|
||||
$env:APPDATA = $previousAppData
|
||||
$env:LOCALAPPDATA = $previousLocalAppData
|
||||
}
|
||||
$outputTask = $p.StandardOutput.ReadToEndAsync()
|
||||
$errorTask = $p.StandardError.ReadToEndAsync()
|
||||
$exited = $p.WaitForExit(30000)
|
||||
|
||||
+35
-6
@@ -9,6 +9,8 @@ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT" || exit 1
|
||||
LOG="logs/quality/latest"
|
||||
mkdir -p "$LOG"
|
||||
GODOT_PROFILE="$ROOT/logs/quality/godot_profile"
|
||||
mkdir -p "$GODOT_PROFILE"
|
||||
|
||||
CHANGED=false
|
||||
[[ "${1:-}" == "--changed" ]] && CHANGED=true
|
||||
@@ -18,8 +20,35 @@ FIXES=()
|
||||
OWNED_GDSCRIPT_ROOTS=(player simulation tests tools world)
|
||||
|
||||
# -- tool detection -----------------------------------------------------------
|
||||
console_godot_path() {
|
||||
local candidate="${1:-}"
|
||||
[[ -z "$candidate" ]] && return 1
|
||||
candidate="${candidate%\"}"
|
||||
candidate="${candidate#\"}"
|
||||
candidate="${candidate//\\//}"
|
||||
if [[ "$candidate" == *.exe ]]; then
|
||||
local console_candidate="${candidate%.exe}_console.exe"
|
||||
if [[ -f "$console_candidate" ]]; then echo "$console_candidate"; return 0; fi
|
||||
fi
|
||||
if [[ -f "$candidate" ]]; then echo "$candidate"; return 0; fi
|
||||
return 1
|
||||
}
|
||||
|
||||
find_project_godot() {
|
||||
local metadata="$ROOT/.godot/editor/project_metadata.cfg"
|
||||
[[ -f "$metadata" ]] || return 1
|
||||
local line path
|
||||
line="$(grep -m 1 '^executable_path=' "$metadata" 2>/dev/null || true)"
|
||||
[[ -n "$line" ]] || return 1
|
||||
path="${line#executable_path=}"
|
||||
path="${path%\"}"
|
||||
path="${path#\"}"
|
||||
console_godot_path "$path"
|
||||
}
|
||||
|
||||
find_godot() {
|
||||
if [[ -n "${GODOT_BIN:-}" ]]; then echo "$GODOT_BIN"; return 0; fi
|
||||
if [[ -n "${GODOT_BIN:-}" ]]; then console_godot_path "$GODOT_BIN" && return 0; echo "$GODOT_BIN"; return 0; fi
|
||||
find_project_godot && return 0
|
||||
for c in godot godot4; do command -v "$c" &>/dev/null && echo "$c" && return 0; done
|
||||
return 1
|
||||
}
|
||||
@@ -148,7 +177,7 @@ fi
|
||||
godot_result="PASS"
|
||||
: > "$LOG/godot-check.log"
|
||||
if need_timeout; then
|
||||
if timeout 30 "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; 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
|
||||
godot_result="PASS"
|
||||
else
|
||||
ec=$?
|
||||
@@ -160,7 +189,7 @@ if need_timeout; then
|
||||
fi
|
||||
fi
|
||||
else
|
||||
if "$GODOT" --headless --path "$ROOT" --script res://tests/simulation_definitions_test.gd >> "$LOG/godot-check.log" 2>&1; then
|
||||
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
|
||||
godot_result="PASS"
|
||||
else
|
||||
godot_result="FAIL"
|
||||
@@ -179,11 +208,11 @@ scenario_result="PASS"
|
||||
for test in tests/*_test.gd; do
|
||||
echo "[RUN] $(basename "$test")" >> "$LOG/scenarios.log"
|
||||
if need_timeout; then
|
||||
if ! timeout 30 "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
if ! APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" timeout 30 "$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 ! "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
elif ! APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" --script "res://$test" >> "$LOG/scenarios.log" 2>&1; then
|
||||
scenario_result="FAIL"
|
||||
ERRORS+=("scenario: $(basename "$test") failed")
|
||||
fi
|
||||
@@ -196,7 +225,7 @@ fi
|
||||
gut_result="SKIPPED"
|
||||
: > "$LOG/gut.log"
|
||||
if [[ -f "addons/gut/gut_cmdln.gd" ]]; then
|
||||
if $GODOT --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then
|
||||
if APPDATA="$GODOT_PROFILE" LOCALAPPDATA="$GODOT_PROFILE" "$GODOT" --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then
|
||||
gut_result="PASS"
|
||||
else
|
||||
gut_result="FAIL"
|
||||
|
||||
Reference in New Issue
Block a user