test(qa): add log-guarded headless QA suites

qa_all.ps1 runs the class scan, smoke, UI, core, input, and UI QA suites, checks PASS markers, and fails on any engine error in the log. New suites cover save migrations, daily logic, frames, level data, navigation, win overlays, and input gestures.
This commit is contained in:
Ratdoku Builder committed 2026-12-02 22:48:09 -06:00
1 parent 48c14864a4
commit 077c08bb5f
7 files changed
+1361

No files matched your search

+122
View File
@@ -0,0 +1,122 @@
param(
[switch]$Build,
[switch]$Screenshots
)
$ErrorActionPreference = "Stop"
$project = Split-Path $PSScriptRoot -Parent
$godot = "C:\Program Files (x86)\Steam\steamapps\common\Godot Engine\godot.windows.opt.tools.64.exe"
if (-not (Test-Path $godot)) {
throw "Godot executable not found."
}
$tempRoot = "C:\Users\enter\AppData\Local\Temp\opencode"
New-Item -ItemType Directory -Force -Path $tempRoot | Out-Null
$logFile = Join-Path $tempRoot "ratdoku-qa.log"
Remove-Item $logFile -Force -ErrorAction SilentlyContinue
$failures = @()
$checks = @()
function Write-Section([string]$text) {
Write-Host "`n=== $text ==="
Add-Content -Path $logFile -Value "=== $text ==="
}
function Quote-Args([string[]]$items) {
return ($items | ForEach-Object {
if ($_ -match '\s') { '"' + $_ + '"' } else { $_ }
}) -join " "
}
function Invoke-Godot([string[]]$arguments, [string]$name, [string]$marker) {
$outFile = Join-Path $tempRoot "qa-$name.out"
$errFile = Join-Path $tempRoot "qa-$name.err"
Remove-Item $outFile, $errFile -Force -ErrorAction SilentlyContinue
$process = Start-Process -FilePath $godot -ArgumentList (Quote-Args $arguments) `
-Wait -PassThru -RedirectStandardOutput $outFile -RedirectStandardError $errFile
$text = ""
if (Test-Path $outFile) { $text += (Get-Content $outFile -Raw) }
if (Test-Path $errFile) { $text += "`n" + (Get-Content $errFile -Raw) }
Add-Content -Path $logFile -Value $text
$hasMarker = $text -match [regex]::Escape($marker)
$hasError = $text -match 'ERROR:|SCRIPT ERROR:|Parse Error|FAIL:|Assertion failed'
if ($process.ExitCode -ne 0 -or -not $hasMarker -or $hasError) {
$script:failures += $name
Write-Host "FAIL $name (exit=$($process.ExitCode) marker=$hasMarker error=$hasError)"
if (-not $hasMarker) { Write-Host " missing marker: $marker" }
}
else {
Write-Host "PASS $name"
$script:checks += $name
}
}
Write-Section "Godot project scan"
Invoke-Godot @("--headless", "--path", $project, "--editor", "--quit") "class-scan" "Godot Engine"
$tests = @(
@{ File = "tools/smoke_test.gd"; Marker = "SMOKE TEST: PASS"; Name = "smoke" },
@{ File = "tools/ui_test.gd"; Marker = "UI TEST: PASS"; Name = "ui" },
@{ File = "tools/qa_core.gd"; Marker = "QA CORE: PASS"; Name = "qa-core" },
@{ File = "tools/qa_ui.gd"; Marker = "QA UI: PASS"; Name = "qa-ui" },
@{ File = "tools/qa_input.gd"; Marker = "QA INPUT: PASS"; Name = "qa-input" }
)
foreach ($test in $tests) {
$path = Join-Path $project $test.File
if (-not (Test-Path $path)) {
$script:failures += $test.Name
Write-Host "FAIL $($test.Name) (script missing: $($test.File))"
continue
}
Write-Section $test.Name
Invoke-Godot @(
"--headless", "--path", $project,
"--script", "res://$($test.File)", "--quit-after", "12000"
) $test.Name $test.Marker
}
if ($Screenshots) {
Write-Section "screenshots"
Invoke-Godot @("--path", $project, "--script", "res://tools/screenshot.gd", "--quit-after", "12000") "screenshots" "Saved"
}
if ($Build) {
Write-Section "android build"
$buildScript = Join-Path $PSScriptRoot "build_android.ps1"
$buildOut = Join-Path $tempRoot "qa-build.out"
$buildErr = Join-Path $tempRoot "qa-build.err"
Remove-Item $buildOut, $buildErr -Force -ErrorAction SilentlyContinue
$buildProc = Start-Process -FilePath "powershell.exe" `
-ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$buildScript`"" `
-Wait -PassThru -RedirectStandardOutput $buildOut -RedirectStandardError $buildErr
$buildOutput = ""
if (Test-Path $buildOut) { $buildOutput += (Get-Content $buildOut -Raw) }
if (Test-Path $buildErr) { $buildOutput += "`n" + (Get-Content $buildErr -Raw) }
Add-Content -Path $logFile -Value $buildOutput
$apk = Join-Path $project "build/Ratdoku.apk"
if ($buildProc.ExitCode -ne 0 -or $buildOutput -notmatch 'DONE' -or -not (Test-Path $apk)) {
$script:failures += "android-build"
Write-Host "FAIL android-build"
}
else {
Write-Host "PASS android-build"
$script:checks += "android-build"
}
}
Write-Section "summary"
Write-Host "Passed: $($checks.Count)"
Write-Host "Failed: $($failures.Count)"
if ($failures.Count -gt 0) {
Write-Host ("Failed suites: " + ($failures -join ", "))
}
Write-Host "Full log: $logFile"
if ($failures.Count -gt 0) { exit 1 }
exit 0