Skip to content

The agent that grows with you

fix(install-e2e): preserve bundled Windows process arrays

Sean McLellan6db1934d0537
diff --git a/.github/workflows/install-e2e-windows-run.yml b/.github/workflows/install-e2e-windows-run.yml
index 7c94b43ccdf..dff4b319558 100644
--- a/.github/workflows/install-e2e-windows-run.yml
+++ b/.github/workflows/install-e2e-windows-run.yml
@@ -134,6 +134,8 @@ jobs:
run: |
node --test tests/install/e2e-assets/windows-bundled-helpers.test.mjs
if ($LASTEXITCODE) { exit $LASTEXITCODE }
+ powershell -NoProfile -ExecutionPolicy Bypass -File tests/install/e2e-assets/windows-bundled-processes.test.ps1
+ if ($LASTEXITCODE) { exit $LASTEXITCODE }
- name: Start recording
uses: ./.github/actions/e2e-screen-record
with:
diff --git a/tests/install/e2e-assets/desktop-smoke-windows.ps1 b/tests/install/e2e-assets/desktop-smoke-windows.ps1
index caf3e2d9c8b..2bd44aab470 100644
--- a/tests/install/e2e-assets/desktop-smoke-windows.ps1
+++ b/tests/install/e2e-assets/desktop-smoke-windows.ps1
@@ -48,4 +48,9 @@ function Close-VerifiedDesktop([string]$Exe, [int]$ProcessId = 0) {
Start-Sleep -Milliseconds 200
} while ((Get-Date) -lt $deadline)
throw 'Verified desktop children did not exit normally; no smoke relaunch attempted'
-}
\ No newline at end of file
+}
+
+function Main-Processes([string]$Exe) {
+ # Prevent the function output pipeline from unrolling zero/one process arrays.
+ return ,@(Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -and $_.ExecutablePath -ieq $Exe -and $_.CommandLine -notmatch '(?:^|\s)--type(?:=|\s)' })
+}
diff --git a/tests/install/e2e-assets/windows-bundled-processes.test.ps1 b/tests/install/e2e-assets/windows-bundled-processes.test.ps1
new file mode 100644
index 00000000000..83018e32cad
--- /dev/null
+++ b/tests/install/e2e-assets/windows-bundled-processes.test.ps1
@@ -0,0 +1,46 @@
+# Pipeline/array contracts only; no package installation or live process changes.
+$ErrorActionPreference = 'Stop'
+Set-StrictMode -Version Latest
+. (Join-Path $PSScriptRoot 'desktop-smoke-windows.ps1')
+
+# Like a CIM process record, this object has no Count property of its own.
+class BundledProcessRecord {
+ [int]$ProcessId
+ [string]$ExecutablePath
+ [string]$CommandLine
+ BundledProcessRecord([int]$Id, [string]$Exe, [string]$Command) {
+ $this.ProcessId = $Id
+ $this.ExecutablePath = $Exe
+ $this.CommandLine = $Command
+ }
+}
+$exe = 'C:\fixture\Hermes.exe'
+$script:processRecords = @()
+function Get-CimInstance([string]$ClassName) {
+ if ($ClassName -cne 'Win32_Process') { throw 'Unexpected CIM query' }
+ $script:processRecords
+}
+
+foreach ($count in 0, 1, 2) {
+ $script:processRecords = @(for ($i = 0; $i -lt $count; $i++) {
+ [BundledProcessRecord]::new(100 + $i, $exe, 'Hermes.exe')
+ })
+ # The OLD identity check and NEW relaunch poll both assign the helper directly.
+ $rows = Main-Processes $exe
+ if ($rows -isnot [array] -or $rows.Count -ne $count) { throw "Lost process array for $count row(s)" }
+ for ($i = 0; $i -lt $count; $i++) {
+ if ($rows[$i].ProcessId -ne 100 + $i) { throw 'Process identity/order lost' }
+ }
+}
+Write-Output 'PASS: zero, one and multiple process rows preserve Count and indexing'
+
+$script:processRecords = @(
+ [BundledProcessRecord]::new(100, $exe.ToUpperInvariant(), 'Hermes.exe'),
+ [BundledProcessRecord]::new(101, $exe, 'Hermes.exe --type=renderer'),
+ [BundledProcessRecord]::new(102, $exe, 'Hermes.exe --type utility'),
+ [BundledProcessRecord]::new(103, 'C:\other\Hermes.exe', 'Hermes.exe'),
+ [BundledProcessRecord]::new(104, '', 'Hermes.exe')
+)
+$rows = Main-Processes $exe
+if ($rows.Count -ne 1 -or $rows[0].ProcessId -ne 100) { throw 'Installed main-process filtering changed' }
+Write-Output 'PASS: exact executable identity excludes Electron children and unrelated processes'
diff --git a/tests/install/windows-bundled-e2e.ps1 b/tests/install/windows-bundled-e2e.ps1
index 569bd9f3cad..307c57efa69 100644
--- a/tests/install/windows-bundled-e2e.ps1
+++ b/tests/install/windows-bundled-e2e.ps1
@@ -63,9 +63,6 @@ function Installed($Side) {
if (-not (Test-Path -LiteralPath $exe)) { throw 'Installed executable missing' }
return @{ package=$pkg; exe=$exe; stamp=$stamp }
}
-function Main-Processes([string]$Exe) {
- return @(Get-CimInstance Win32_Process | Where-Object { $_.ExecutablePath -and $_.ExecutablePath -ieq $Exe -and $_.CommandLine -notmatch '(?:^|\s)--type(?:=|\s)' })
-}
$Feed = Join-Path $Work 'feed'
New-Item -ItemType Directory -Path $Feed | Out-Null
Copy-Item -LiteralPath $m.old.artifact.path -Destination (Join-Path $Feed 'old.msixbundle')