feat: add replay-test.ps1 orchestration script
Browse filesCo-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- replay-test.ps1 +87 -0
replay-test.ps1
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# replay-test.ps1 - Automated replay-based testing
|
| 2 |
+
# Usage: powershell -File replay-test.ps1 [replay-file]
|
| 3 |
+
|
| 4 |
+
param(
|
| 5 |
+
[string]$ReplayFile = "testdata\replays\bots.WAgame"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
$ErrorActionPreference = "Stop"
|
| 9 |
+
|
| 10 |
+
$gameDir = "I:\games\SteamLibrary\steamapps\common\Worms Armageddon"
|
| 11 |
+
$waExe = "$gameDir\WA.exe"
|
| 12 |
+
$src = "target\i686-pc-windows-msvc\release"
|
| 13 |
+
$logDir = "testdata\logs"
|
| 14 |
+
|
| 15 |
+
# Resolve replay file to absolute path
|
| 16 |
+
if (-not [System.IO.Path]::IsPathRooted($ReplayFile)) {
|
| 17 |
+
$ReplayFile = Join-Path (Get-Location) $ReplayFile
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
if (-not (Test-Path $ReplayFile)) {
|
| 21 |
+
Write-Error "Replay file not found: $ReplayFile"
|
| 22 |
+
exit 1
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
# 1. Build
|
| 26 |
+
Write-Host "Building..." -ForegroundColor Cyan
|
| 27 |
+
cargo build --release -p openwa-wormkit -p openwa-validator
|
| 28 |
+
if ($LASTEXITCODE -ne 0) { exit 1 }
|
| 29 |
+
|
| 30 |
+
# 2. Deploy
|
| 31 |
+
Write-Host "Deploying to $gameDir..." -ForegroundColor Cyan
|
| 32 |
+
Copy-Item "$src\openwa_wormkit.dll" "$gameDir\wkOpenWA.dll"
|
| 33 |
+
Copy-Item "$src\openwa_validator.dll" "$gameDir\wkOpenWAValidator.dll"
|
| 34 |
+
|
| 35 |
+
# 3. Clear old logs
|
| 36 |
+
Remove-Item "$gameDir\OpenWA.log" -ErrorAction SilentlyContinue
|
| 37 |
+
Remove-Item "$gameDir\OpenWA_validation.log" -ErrorAction SilentlyContinue
|
| 38 |
+
|
| 39 |
+
# 4. Launch WA.exe with replay, env var set
|
| 40 |
+
Write-Host "Launching WA.exe with replay: $ReplayFile" -ForegroundColor Cyan
|
| 41 |
+
Write-Host " (Auto-capture mode: will exit after 30s)" -ForegroundColor Yellow
|
| 42 |
+
|
| 43 |
+
$env:OPENWA_REPLAY_TEST = "1"
|
| 44 |
+
$proc = Start-Process -FilePath $waExe -ArgumentList "`"$ReplayFile`"" -PassThru
|
| 45 |
+
$proc.WaitForExit()
|
| 46 |
+
$env:OPENWA_REPLAY_TEST = $null
|
| 47 |
+
|
| 48 |
+
Write-Host "WA.exe exited with code $($proc.ExitCode)" -ForegroundColor Cyan
|
| 49 |
+
|
| 50 |
+
# 5. Copy logs back
|
| 51 |
+
if (-not (Test-Path $logDir)) {
|
| 52 |
+
New-Item -ItemType Directory -Path $logDir | Out-Null
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
$timestamp = Get-Date -Format "yyyy-MM-dd_HH-mm-ss"
|
| 56 |
+
|
| 57 |
+
if (Test-Path "$gameDir\OpenWA_validation.log") {
|
| 58 |
+
Copy-Item "$gameDir\OpenWA_validation.log" "$logDir\validation_$timestamp.log"
|
| 59 |
+
Copy-Item "$gameDir\OpenWA_validation.log" "$logDir\validation_latest.log"
|
| 60 |
+
Write-Host "Validation log copied." -ForegroundColor Green
|
| 61 |
+
} else {
|
| 62 |
+
Write-Host "WARNING: No validation log found!" -ForegroundColor Red
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
if (Test-Path "$gameDir\OpenWA.log") {
|
| 66 |
+
Copy-Item "$gameDir\OpenWA.log" "$logDir\openwa_$timestamp.log"
|
| 67 |
+
Copy-Item "$gameDir\OpenWA.log" "$logDir\openwa_latest.log"
|
| 68 |
+
Write-Host "OpenWA log copied." -ForegroundColor Green
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
# 6. Print summary
|
| 72 |
+
Write-Host ""
|
| 73 |
+
Write-Host "=== Validation Summary ===" -ForegroundColor Cyan
|
| 74 |
+
if (Test-Path "$logDir\validation_latest.log") {
|
| 75 |
+
$content = Get-Content "$logDir\validation_latest.log" -Raw
|
| 76 |
+
$passes = ([regex]::Matches($content, "\[PASS\]")).Count
|
| 77 |
+
$fails = ([regex]::Matches($content, "\[FAIL\]")).Count
|
| 78 |
+
Write-Host " PASS: $passes" -ForegroundColor Green
|
| 79 |
+
Write-Host " FAIL: $fails" -ForegroundColor $(if ($fails -gt 0) { "Red" } else { "Green" })
|
| 80 |
+
|
| 81 |
+
if ($content -match "Auto-capture complete") {
|
| 82 |
+
Write-Host " Auto-capture: completed successfully" -ForegroundColor Green
|
| 83 |
+
} else {
|
| 84 |
+
Write-Host " Auto-capture: NOT found in log (may not have reached gameplay)" -ForegroundColor Yellow
|
| 85 |
+
}
|
| 86 |
+
}
|
| 87 |
+
Write-Host " Logs: $logDir\" -ForegroundColor Gray
|