From 82b48cd089b55e47f5112b2801f2eb48c1c002dc Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Tue, 18 Aug 2026 10:48:06 +0200 Subject: [PATCH] Test EveUnity through isolated package consumers --- .gitignore | 3 + TestProject/Packages/packages-lock.json | 8 +-- .../org.gamecult.eve.unity-scene/package.json | 4 +- scripts/run-package-tests.ps1 | 69 +++++++++++++------ scripts/run-release-consumer-tests.ps1 | 7 +- 5 files changed, 64 insertions(+), 27 deletions(-) diff --git a/.gitignore b/.gitignore index 2c9c34e..975deb4 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/TestProject/Packages/packages-lock.json b/TestProject/Packages/packages-lock.json index bbda013..3f117a0 100644 --- a/TestProject/Packages/packages-lock.json +++ b/TestProject/Packages/packages-lock.json @@ -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": { diff --git a/packages/org.gamecult.eve.unity-scene/package.json b/packages/org.gamecult.eve.unity-scene/package.json index 49bbacd..41e1b2e 100644 --- a/packages/org.gamecult.eve.unity-scene/package.json +++ b/packages/org.gamecult.eve.unity-scene/package.json @@ -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", diff --git a/scripts/run-package-tests.ps1 b/scripts/run-package-tests.ps1 index 2c9b78f..acd058d 100644 --- a/scripts/run-package-tests.ps1 +++ b/scripts/run-package-tests.ps1 @@ -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" diff --git a/scripts/run-release-consumer-tests.ps1 b/scripts/run-release-consumer-tests.ps1 index af0dd6d..aa57c7f 100644 --- a/scripts/run-release-consumer-tests.ps1 +++ b/scripts/run-release-consumer-tests.ps1 @@ -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)"