This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
EveUnity/scripts/run-playmode-capture.ps1
2026-07-10 03:34:56 +01:00

46 lines
2.1 KiB
PowerShell

param(
[string] $UnityExe = "C:\Program Files\Unity\Hub\Editor\6000.4.2f1\Editor\Unity.exe",
[string] $CultLibRoot = "E:\Projects\CultLib",
[string] $OutputDirectory = "artifacts\playmode"
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $PSScriptRoot
$projectRoot = Join-Path $repoRoot "TestProject"
$outputRoot = if ([System.IO.Path]::IsPathRooted($OutputDirectory)) { $OutputDirectory } else { Join-Path $repoRoot $OutputDirectory }
$resultsPath = Join-Path $outputRoot "results.xml"
$logPath = Join-Path $outputRoot "unity.log"
$capturePath = Join-Path $outputRoot "world-smoke.png"
foreach ($required in @($UnityExe, $projectRoot, (Join-Path $CultLibRoot "scripts\build-unity-package.ps1"))) {
if (-not (Test-Path -LiteralPath $required)) { throw "Required EveUnity PlayMode path not found: $required" }
}
New-Item -ItemType Directory -Force -Path $outputRoot | Out-Null
powershell -ExecutionPolicy Bypass -File (Join-Path $CultLibRoot "scripts\build-unity-package.ps1")
if ($LASTEXITCODE -ne 0) { throw "CultLib Unity package build failed with exit code $LASTEXITCODE" }
$env:EVEUNITY_CAPTURE_PATH = $capturePath
$arguments = @(
"-batchmode", "-projectPath", $projectRoot,
"-runTests", "-testPlatform", "PlayMode",
"-assemblyNames", "GameCult.EveUnity.GenericClient.PlayModeTests",
"-testResults", $resultsPath, "-logFile", $logPath
)
$process = Start-Process -FilePath $UnityExe -ArgumentList $arguments -Wait -PassThru -WindowStyle Hidden
if ($process.ExitCode -ne 0) {
Get-Content -LiteralPath $logPath -Tail 120
throw "EveUnity PlayMode capture failed with exit code $($process.ExitCode)"
}
[xml] $results = Get-Content -LiteralPath $resultsPath -Raw
$run = $results.SelectSingleNode("//test-run")
if ($null -eq $run -or [int] $run.total -eq 0 -or [int] $run.failed -gt 0) {
throw "EveUnity PlayMode tests did not pass: $resultsPath"
}
if (-not (Test-Path -LiteralPath $capturePath) -or (Get-Item -LiteralPath $capturePath).Length -lt 1024) {
throw "EveUnity PlayMode capture is missing or empty: $capturePath"
}
Write-Host "EveUnity PlayMode tests: $($run.passed) passed"
Write-Host "Capture: $capturePath"