Skip to content

The agent that grows with you

test(desktop): the MSIX plugin smoke runs with a user's environment, not the CI driver's

Tekniumf470bf3a32c9
diff --git a/tests/install/e2e-assets/windows-bundle-plugin-smoke.ps1 b/tests/install/e2e-assets/windows-bundle-plugin-smoke.ps1
index 2da501fe6df..544d5f562e4 100644
--- a/tests/install/e2e-assets/windows-bundle-plugin-smoke.ps1
+++ b/tests/install/e2e-assets/windows-bundle-plugin-smoke.ps1
@@ -86,9 +86,21 @@ public static class HermesBasicUser {
}
'@
+# The batch starts from this process's environment. The CI driver exports its own PM home
+# (HERMES_HOME, HERMES_RUNTIME_DIR, HERMES_PYTHON); a CLI that inherits them builds on the
+# driver's Python instead of the package's, and the bug never shows. Start clean, as a user does.
+function Get-UserEnvironmentReset {
+ $lines = @(Get-ChildItem env: | Where-Object { $_.Name -match '^(HERMES_|UV_|PYTHON|VIRTUAL_ENV|CONDA)' } |
+ ForEach-Object { 'set "' + $_.Name + '="' })
+ $driverRoots = @($env:HERMES_HOME, $env:HERMES_RUNTIME_DIR) | Where-Object { $_ }
+ $path = @($env:PATH -split ';' | Where-Object { $entry = $_; $_ -and -not @($driverRoots | Where-Object {
+ $entry.StartsWith($_, [StringComparison]::OrdinalIgnoreCase) }).Count })
+ return $lines + @('set "PATH=' + ($path -join ';') + '"')
+}
+
function Invoke-BasicUserBatch([string]$Name, [string[]]$Lines, [string]$Directory, [int]$TimeoutMinutes) {
$batch = Join-Path $Directory "$Name.cmd"
- Set-Content -LiteralPath $batch -Encoding ASCII -Value (@('@echo off') + $Lines)
+ Set-Content -LiteralPath $batch -Encoding ASCII -Value (@('@echo off') + (Get-UserEnvironmentReset) + $Lines)
return [HermesBasicUser]::Run("cmd.exe /d /c `"$batch`"", $Directory, [uint32]($TimeoutMinutes * 60000))
}
@@ -131,6 +143,12 @@ function Test-BundlePluginInstall([string]$Root, [string]$Out) {
$json = [regex]::Match($listing, '(?ms)^\[.*^\]')
$rows = if ($json.Success) { @($json.Value | ConvertFrom-Json) } else { @() }
$row = @($rows | Where-Object { $_.name -ceq 'msix-smoke-plugin' })
+ $installLog = if (Test-Path -LiteralPath (Join-Path $scratch 'install.log')) { Get-Content -Raw -LiteralPath (Join-Path $scratch 'install.log') } else { '' }
+ foreach ($driverRoot in @($env:HERMES_HOME, $env:HERMES_RUNTIME_DIR) | Where-Object { $_ }) {
+ if ($installLog.IndexOf($driverRoot, [StringComparison]::OrdinalIgnoreCase) -ge 0) {
+ throw "Plugin install used the CI driver's PM home ($driverRoot), not the package's"
+ }
+ }
if ($row.Count -ne 1 -or $row[0].status -cne 'enabled') {
$log = Join-Path $scratch 'install.log'
$tail = if (Test-Path -LiteralPath $log) { (Get-Content -LiteralPath $log -Tail 40) -join "`n" } else { '(no install log)' }