diff --git a/scripts/deploy_windows_runner_dogfood.ps1 b/scripts/deploy_windows_runner_dogfood.ps1 index 886c4a14..ba6fa9a0 100644 --- a/scripts/deploy_windows_runner_dogfood.ps1 +++ b/scripts/deploy_windows_runner_dogfood.ps1 @@ -206,7 +206,10 @@ try { -AllowVersionMismatch:$AllowVersionMismatch $candidateReadyObservation = $candidateReady.Observation $null = Assert-CapturedPrimaryRunnerIdentity -Identity $newPrimary - if ((Get-PrimaryRunnerProcesses -ExactPath $RunnerPath).Count -ne 1) { + # Windows PowerShell 5.1 unwraps a single pipeline object, so a bare + # `(Get-PrimaryRunnerProcesses ...).Count` is `$null` for the healthy + # exactly-one case. Force array semantics before checking cardinality. + if (@(Get-PrimaryRunnerProcesses -ExactPath $RunnerPath).Count -ne 1) { throw "New Runner did not remain the exactly-one primary Runner after readiness" } diff --git a/scripts/test_windows_runner_readiness.ps1 b/scripts/test_windows_runner_readiness.ps1 index 55e919ea..bcc6b514 100644 --- a/scripts/test_windows_runner_readiness.ps1 +++ b/scripts/test_windows_runner_readiness.ps1 @@ -204,6 +204,10 @@ $deployTokens = $null $deployParseErrors = $null $deployAst = [System.Management.Automation.Language.Parser]::ParseFile($deployPath, [ref]$deployTokens, [ref]$deployParseErrors) Assert-Equal 0 @($deployParseErrors).Count "deployment helper parser errors" +# Windows PowerShell 5.1 unwraps a one-item pipeline result to a scalar. +# The final local exactly-one-primary proof must therefore force array semantics; +# otherwise the healthy one-primary case observes `$null` for `.Count` and rolls back. +Assert-True ($deployAst.Extent.Text -match 'if\s*\(\s*@\(Get-PrimaryRunnerProcesses\s+-ExactPath\s+\$RunnerPath\)\.Count\s+-ne\s+1\s*\)') "deployment helper exactly-one primary recheck is not array-wrapped" $allowVersionParameters = @($deployAst.ParamBlock.Parameters | Where-Object { $_.Name.VariablePath.UserPath -eq 'AllowVersionMismatch' }) Assert-Equal 1 $allowVersionParameters.Count "deployment helper does not expose exactly one AllowVersionMismatch opt-in" $deployReadinessCalls = @($deployAst.FindAll({