Own Unity package tests in generic client
This commit is contained in:
parent
9af9e2c4fb
commit
d8d0bd5eff
7 changed files with 104 additions and 110 deletions
|
|
@ -1,45 +1,42 @@
|
|||
param(
|
||||
[string] $AetheriaRoot = "E:\Projects\Aetheria",
|
||||
[string] $UnityExe = "C:\Program Files\Unity\Hub\Editor\6000.4.2f1\Editor\Unity.exe",
|
||||
[string] $OutputRoot = "artifacts\uitoolkit-consumer"
|
||||
[string] $CultLibRoot = "E:\Projects\CultLib",
|
||||
[string] $ProjectRoot = "TestProject",
|
||||
[string] $OutputRoot = "artifacts\uitoolkit-tests"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$repoRoot = Split-Path -Parent $PSScriptRoot
|
||||
$manifestPath = Join-Path $AetheriaRoot "Packages\manifest.json"
|
||||
$projectPath = if ([IO.Path]::IsPathRooted($ProjectRoot)) { $ProjectRoot } else { Join-Path $repoRoot $ProjectRoot }
|
||||
$output = if ([IO.Path]::IsPathRooted($OutputRoot)) { $OutputRoot } else { Join-Path $repoRoot $OutputRoot }
|
||||
foreach ($required in @($manifestPath, $UnityExe, (Join-Path $repoRoot "packages\org.gamecult.eve.unity-uitoolkit"))) {
|
||||
$cultLibBuilder = Join-Path $CultLibRoot "scripts\build-unity-package.ps1"
|
||||
foreach ($required in @($UnityExe, $projectPath, $cultLibBuilder)) {
|
||||
if (-not (Test-Path -LiteralPath $required)) { throw "Required EveUnity UI Toolkit test path not found: $required" }
|
||||
}
|
||||
|
||||
powershell -ExecutionPolicy Bypass -File $cultLibBuilder
|
||||
if ($LASTEXITCODE -ne 0) { throw "CultLib Unity package build failed with exit code $LASTEXITCODE" }
|
||||
|
||||
$runRoot = Join-Path $output (Get-Date -Format "yyyyMMddTHHmmss")
|
||||
New-Item -ItemType Directory -Force -Path $runRoot | Out-Null
|
||||
$resultsPath = Join-Path $runRoot "unity-editmode-results.xml"
|
||||
$logPath = Join-Path $runRoot "unity-editmode.log"
|
||||
$originalManifest = Get-Content -LiteralPath $manifestPath -Raw
|
||||
try {
|
||||
$manifest = $originalManifest | ConvertFrom-Json
|
||||
$testables = @($manifest.testables) | Where-Object { $_ }
|
||||
if ($testables -notcontains "org.gamecult.eve.unity-uitoolkit") { $testables += "org.gamecult.eve.unity-uitoolkit" }
|
||||
if ($manifest.PSObject.Properties.Name -contains "testables") { $manifest.testables = $testables }
|
||||
else { $manifest | Add-Member -NotePropertyName testables -NotePropertyValue $testables }
|
||||
$manifest | ConvertTo-Json -Depth 32 | Set-Content -LiteralPath $manifestPath
|
||||
$arguments = @(
|
||||
"-batchmode", "-projectPath", $AetheriaRoot,
|
||||
"-runTests", "-testPlatform", "EditMode",
|
||||
"-assemblyNames", "GameCult.Eve.UnityUIToolkit.Tests",
|
||||
"-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 UI Toolkit tests failed with exit code $($process.ExitCode)"
|
||||
}
|
||||
} finally {
|
||||
Set-Content -NoNewline -LiteralPath $manifestPath -Value $originalManifest
|
||||
$arguments = @(
|
||||
"-batchmode", "-projectPath", $projectPath,
|
||||
"-runTests", "-testPlatform", "EditMode",
|
||||
"-assemblyNames", "GameCult.Eve.UnityUIToolkit.Tests",
|
||||
"-testResults", $resultsPath, "-logFile", $logPath
|
||||
)
|
||||
$process = Start-Process -FilePath $UnityExe -ArgumentList $arguments -Wait -PassThru -WindowStyle Hidden
|
||||
if ($process.ExitCode -ne 0) {
|
||||
if (Test-Path -LiteralPath $logPath) { Get-Content -LiteralPath $logPath -Tail 120 }
|
||||
throw "EveUnity UI Toolkit tests 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 UI Toolkit tests did not pass: $resultsPath" }
|
||||
Write-Host "EveUnity UI Toolkit tests: $($run.passed) passed, $($run.total) total"
|
||||
if ($null -eq $run -or [int]$run.total -eq 0 -or [int]$run.failed -gt 0) {
|
||||
throw "EveUnity UI Toolkit tests did not pass: $resultsPath"
|
||||
}
|
||||
Write-Host "EveUnity generic UI Toolkit tests: $($run.passed) passed, $($run.total) total"
|
||||
Write-Host "Consumer: $projectPath"
|
||||
|
|
|
|||
Reference in a new issue