| @@ -5,7 +5,6 @@ param([Parameter(Mandatory)][string]$Installer) |
| 5 | 5 | . (Join-Path $PSScriptRoot 'windows-common.ps1') |
| 6 | 6 | if (-not $IsWindows) { throw 'Installation smoke tests must run on Windows.' } |
| 7 | 7 | $target = Join-Path $env:LOCALAPPDATA ('Programs/Cage-test-' + [guid]::NewGuid().ToString('N')) |
| 8 | | −删除:$report = Join-Path ([IO.Path]::GetTempPath()) ('cage-smoke-' + [guid]::NewGuid().ToString('N') + '.json') |
| 9 | 8 | $savedKey = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall\ClaudeCage' |
| 10 | 9 | if (Test-Path $savedKey) { throw 'Use a disposable Windows user without an existing Cage installation.' } |
| 11 | 10 | $fixture = Join-Path $PSScriptRoot 'personal-data-fixture.mjs' |
| @@ -74,17 +73,10 @@ Invoke-BuildTool (Join-Path $target 'resources/cage.exe') @('verify-web-assets') |
| 74 | 73 | Invoke-BuildTool (Join-Path $target 'resources/mihomo.exe') @('-v') |
| 75 | 74 | Invoke-BuildTool (Join-Path $target 'resources/runtime/qemu/qemu-system-x86_64.exe') @('--version') |
| 76 | 75 | Invoke-BuildTool (Join-Path $target 'resources/runtime/openssh/ssh.exe') @('-V') |
| 77 | | −删除:$savedProfile = $env:CLAUDE_CAGE_CONFIG |
| 78 | | −删除:try { |
| 79 | | −删除: # The UI test owns a separate profile; the installer must preserve the |
| 80 | | −删除: # pre-existing default profile without asking the app to parse test bytes. |
| 81 | | −删除: $env:CLAUDE_CAGE_CONFIG = Join-Path ([IO.Path]::GetTempPath()) ('cage-ui-profile-' + [guid]::NewGuid().ToString('N') + '/config.json') |
| 82 | | −删除: $window = Start-Process -FilePath (Join-Path $target 'Cage.exe') -ArgumentList @('--smoke-test', "`"$report`"") -PassThru |
| 83 | | −删除: if (-not $window.WaitForExit(180000)) { throw 'Cage WebView2/workbench smoke test timed out.' } |
| 84 | | −删除: if ($window.ExitCode -ne 0 -or -not (Test-Path -LiteralPath $report)) { throw "Cage desktop smoke test failed ($($window.ExitCode))." } |
| 85 | | −删除:} finally { $env:CLAUDE_CAGE_CONFIG = $savedProfile } |
| 76 | +新增:# Use the same isolated profile, process lifetime and retained diagnostics as |
| 77 | +新增:# build acceptance. The pre-existing default profile holds preservation markers. |
| 78 | +新增:Assert-WindowsWorkbench -AppDirectory $target |
| 86 | 79 | Assert-PersonalData |
| 87 | | −删除:Get-Content -LiteralPath $report |
| 88 | 80 | # A locked installed executable must fail before replacing the installation. |
| 89 | 81 | $before = (Get-FileHash -LiteralPath (Join-Path $target 'Cage.exe') -Algorithm SHA256).Hash |
| 90 | 82 | $locked = [IO.File]::Open((Join-Path $target 'Cage.exe'), [IO.FileMode]::Open, [IO.FileAccess]::Read, [IO.FileShare]::Read) |
| @@ -109,11 +101,15 @@ Assert-PersonalData |
| 109 | 101 | $uninstall = Start-Process -FilePath (Join-Path $target 'Uninstall.exe') -ArgumentList @('/S') -PassThru |
| 110 | 102 | if (-not $uninstall.WaitForExit(120000) -or $uninstall.ExitCode -ne 0) { throw 'Uninstall failed.' } |
| 111 | 103 | # NSIS may relaunch its uninstaller from TEMP so that it can delete the original. |
| 104 | +新增:# The launcher can disappear before the worker clears registration and shortcuts. |
| 112 | 105 | $deadline = [DateTime]::UtcNow.AddSeconds(120) |
| 113 | | −删除:while ((Test-Path -LiteralPath (Join-Path $target 'Uninstall.exe')) -and [DateTime]::UtcNow -lt $deadline) { Start-Sleep -Milliseconds 200 } |
| 106 | +新增:while (((Test-Path -LiteralPath $target) -or (Test-Path $savedKey) -or |
| 107 | +新增: (Test-Path -LiteralPath $desktopShortcut) -or (Test-Path -LiteralPath $startMenuDirectory)) -and |
| 108 | +新增: [DateTime]::UtcNow -lt $deadline) { Start-Sleep -Milliseconds 200 } |
| 114 | 109 | if (Test-Path -LiteralPath (Join-Path $target 'Cage.exe')) { throw 'Uninstall left Cage.exe behind.' } |
| 115 | 110 | if (Test-Path -LiteralPath (Join-Path $target 'Uninstall.exe')) { throw 'Uninstall left its launcher behind.' } |
| 116 | 111 | if (Test-Path -LiteralPath $target) { throw 'Uninstall left packaged files or directories that would block installation into the same folder.' } |
| 112 | +新增:if (Test-Path $savedKey) { throw 'Uninstall left the Cage registration behind.' } |
| 117 | 113 | Assert-PersonalData |
| 118 | 114 | Assert-Shortcuts $false $false |
| 119 | 115 | Write-Host 'Install, WebView2 workbench, reinstall, uninstall and user-data preservation passed. VM startup was not tested.' |