Test EveUnity through isolated package consumers

This commit is contained in:
Meta Vens 2026-08-18 10:48:06 +02:00
commit 82b48cd089
5 changed files with 64 additions and 27 deletions

3
.gitignore vendored
View file

@ -9,3 +9,6 @@ TestProject/UserSettings/
obj/
*.csproj
*.sln
packages/org.gamecult.eve.surface/bin~/
packages/org.gamecult.eve.surface/obj~/
packages/org.gamecult.eve.surface/Directory.Build.props.meta

View file

@ -145,10 +145,10 @@
"depth": 0,
"source": "local",
"dependencies": {
"org.gamecult.cultlib": "1.0.45",
"org.gamecult.cultlib": "1.0.47",
"org.gamecult.eve.plugin-fields": "0.2.3",
"org.gamecult.eve.surface": "0.3.0",
"org.gamecult.eve.unity-uitoolkit": "0.1.3",
"org.gamecult.eve.surface": "0.3.2",
"org.gamecult.eve.unity-uitoolkit": "0.1.4",
"com.unity.mathematics": "1.3.2",
"com.unity.render-pipelines.universal": "17.4.0",
"com.unity.modules.particlesystem": "1.0.0"
@ -159,7 +159,7 @@
"depth": 0,
"source": "local",
"dependencies": {
"org.gamecult.eve.surface": "0.3.0"
"org.gamecult.eve.surface": "0.3.2"
}
},
"com.unity.modules.assetbundle": {

View file

@ -1,11 +1,11 @@
{
"name": "org.gamecult.eve.unity-scene",
"displayName": "Eve Unity Scene Lowering",
"version": "0.3.107",
"version": "0.3.108",
"unity": "6000.0",
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
"dependencies": {
"org.gamecult.cultlib": "1.0.46",
"org.gamecult.cultlib": "1.0.47",
"org.gamecult.eve.plugin-fields": "0.2.3",
"org.gamecult.eve.surface": "0.3.2",
"org.gamecult.eve.unity-uitoolkit": "0.1.4",

View file

@ -1,26 +1,35 @@
param(
[string] $UnityExe = "C:\Program Files\Unity\Hub\Editor\6000.4.2f1\Editor\Unity.exe",
[string] $CultLibRoot = "E:\Projects\CultLib",
[string] $CultLibRoot = "",
[string] $EveRoot = "",
[string] $EvePluginsRoot = "",
[string] $ProjectRoot = "TestProject",
[string] $OutputRoot = "artifacts\package-tests"
)
$ErrorActionPreference = "Stop"
$repoRoot = Split-Path -Parent $PSScriptRoot
$workspaceRoot = Split-Path -Parent $repoRoot
if ([string]::IsNullOrWhiteSpace($CultLibRoot)) { $CultLibRoot = Join-Path $workspaceRoot "CultLib" }
if ([string]::IsNullOrWhiteSpace($EveRoot)) { $EveRoot = Join-Path $workspaceRoot "Eve" }
if ([string]::IsNullOrWhiteSpace($EvePluginsRoot)) { $EvePluginsRoot = Join-Path $workspaceRoot "EvePlugins" }
$projectPath = if ([IO.Path]::IsPathRooted($ProjectRoot)) { $ProjectRoot } else { Join-Path $repoRoot $ProjectRoot }
$output = if ([IO.Path]::IsPathRooted($OutputRoot)) { $OutputRoot } else { Join-Path $repoRoot $OutputRoot }
$cultLibBuilder = Join-Path $CultLibRoot "scripts\build-unity-package.ps1"
$obsoleteSurfacePackage = Join-Path $repoRoot "packages\org.gamecult.eve.surface"
$testManifestPath = Join-Path $projectPath "Packages\manifest.json"
if (Test-Path -LiteralPath $obsoleteSurfacePackage) {
$obsoleteSurfaceSource = @("package.json", "Runtime", "Editor") |
ForEach-Object { Join-Path $obsoleteSurfacePackage $_ } |
Where-Object { Test-Path -LiteralPath $_ }
if ($obsoleteSurfaceSource.Count -gt 0) {
throw "EveUnity must consume the Eve-owned surface package; duplicate source exists at $obsoleteSurfacePackage"
}
$testManifest = Get-Content -LiteralPath $testManifestPath -Raw | ConvertFrom-Json
$surfaceDependency = [string]$testManifest.dependencies."org.gamecult.eve.surface"
if ($surfaceDependency -notmatch '(?i)Eve/packages/org\.gamecult\.eve\.surface$') {
throw "EveUnity test consumer must resolve org.gamecult.eve.surface from Eve; found '$surfaceDependency'."
}
foreach ($required in @($UnityExe, $projectPath, $cultLibBuilder)) {
foreach ($required in @(
$UnityExe,
$projectPath,
$cultLibBuilder,
(Join-Path $EveRoot "packages\org.gamecult.eve.surface\package.json"),
(Join-Path $EvePluginsRoot "plugins\eve-plugin-fields\unity\org.gamecult.eve.plugin-fields\package.json")
)) {
if (-not (Test-Path -LiteralPath $required)) { throw "Required EveUnity package-test path not found: $required" }
}
@ -28,23 +37,43 @@ powershell -ExecutionPolicy Bypass -File $cultLibBuilder
if ($LASTEXITCODE -ne 0) { throw "CultLib Unity package build failed with exit code $LASTEXITCODE" }
$builtCultLibPackage = Join-Path $CultLibRoot "artifacts\unity\org.gamecult.cultlib"
$stagedDependenciesRoot = Join-Path $repoRoot "artifacts\test-dependencies"
$stagedCultLibPackage = Join-Path $stagedDependenciesRoot "org.gamecult.cultlib"
if (-not (Test-Path -LiteralPath $builtCultLibPackage)) {
throw "CultLib Unity package build did not produce: $builtCultLibPackage"
}
New-Item -ItemType Directory -Force -Path $stagedDependenciesRoot | Out-Null
if (Test-Path -LiteralPath $stagedCultLibPackage) {
[IO.Directory]::Delete($stagedCultLibPackage, $true)
}
Copy-Item -LiteralPath $builtCultLibPackage -Destination $stagedCultLibPackage -Recurse
$runRoot = Join-Path $output (Get-Date -Format "yyyyMMddTHHmmss")
New-Item -ItemType Directory -Force -Path $runRoot | Out-Null
$consumerPath = Join-Path $runRoot "consumer"
$consumerPackagesPath = Join-Path $consumerPath "Packages"
$stagedDependenciesRoot = Join-Path $runRoot "dependencies"
New-Item -ItemType Directory -Force -Path $consumerPath, $consumerPackagesPath, $stagedDependenciesRoot | Out-Null
Copy-Item -LiteralPath (Join-Path $projectPath "Assets") -Destination (Join-Path $consumerPath "Assets") -Recurse
Copy-Item -LiteralPath (Join-Path $projectPath "ProjectSettings") -Destination (Join-Path $consumerPath "ProjectSettings") -Recurse
$dependencySources = [ordered]@{
"org.gamecult.cultlib" = $builtCultLibPackage
"org.gamecult.eve.plugin-fields" = Join-Path $EvePluginsRoot "plugins\eve-plugin-fields\unity\org.gamecult.eve.plugin-fields"
"org.gamecult.eve.surface" = Join-Path $EveRoot "packages\org.gamecult.eve.surface"
"org.gamecult.eve.unity-scene" = Join-Path $repoRoot "packages\org.gamecult.eve.unity-scene"
"org.gamecult.eve.unity-uitoolkit" = Join-Path $repoRoot "packages\org.gamecult.eve.unity-uitoolkit"
}
foreach ($entry in $dependencySources.GetEnumerator()) {
Copy-Item -LiteralPath $entry.Value -Destination (Join-Path $stagedDependenciesRoot $entry.Key) -Recurse
}
$manifest = Get-Content -LiteralPath (Join-Path $projectPath "Packages\manifest.json") -Raw | ConvertFrom-Json
foreach ($packageId in $dependencySources.Keys) {
$manifest.dependencies.$packageId = "file:../../dependencies/$packageId"
}
$manifestJson = $manifest | ConvertTo-Json -Depth 20
[IO.File]::WriteAllText(
(Join-Path $consumerPackagesPath "manifest.json"),
$manifestJson,
[Text.UTF8Encoding]::new($false))
$resultsPath = Join-Path $runRoot "unity-editmode-results.xml"
$logPath = Join-Path $runRoot "unity-editmode.log"
$arguments = @(
"-batchmode", "-projectPath", $projectPath,
"-batchmode", "-projectPath", $consumerPath,
"-runTests", "-testPlatform", "EditMode",
"-assemblyNames", "GameCult.Eve.UnityScene.Tests",
"-testResults", $resultsPath, "-logFile", $logPath
@ -72,5 +101,5 @@ if ($null -eq $run -or [int]$run.total -eq 0 -or [int]$run.failed -gt 0) {
throw "EveUnity package tests did not pass: $resultsPath"
}
Write-Host "EveUnity generic package tests: $($run.passed) passed, $($run.total) total"
Write-Host "Consumer: $projectPath"
Write-Host "CultLib package: $stagedCultLibPackage"
Write-Host "Isolated consumer: $consumerPath"
Write-Host "Staged dependencies: $stagedDependenciesRoot"

View file

@ -15,7 +15,12 @@ $arguments = @(
"-testResults", $results, "-logFile", $logPath
)
$process = Start-Process -FilePath $UnityExe -ArgumentList $arguments -WorkingDirectory $repoRoot -Wait -PassThru -WindowStyle Hidden
$process = Start-Process -FilePath $UnityExe -ArgumentList $arguments -WorkingDirectory $repoRoot -PassThru -WindowStyle Hidden
if (-not $process.WaitForExit([int][TimeSpan]::FromMinutes(10).TotalMilliseconds)) {
Stop-Process -Id $process.Id -Force -ErrorAction SilentlyContinue
if (Test-Path $logPath) { Get-Content -LiteralPath $logPath -Tail 120 }
throw "Released EveUnity package consumer tests timed out after 10 minutes (Unity PID $($process.Id))."
}
if ($process.ExitCode -ne 0) {
if (Test-Path $logPath) { Get-Content -LiteralPath $logPath -Tail 120 }
throw "Released EveUnity package consumer tests failed with exit code $($process.ExitCode)"