fix: [#958] Windows installer Pester job — inject env in child session

Merged
AN
5mo ago
+29-10

What does this PR do?

Fixes the flaky Windows Installer (Pester) CI job. Invoke-Installer in test/windows/install.Tests.ps1 now applies the requested PROCESSOR_* env vars inside the child pwsh session (via a -Command preamble) instead of mutating the Pester host's Process-scope environment and relying on inheritance into & pwsh -File.

PROCESSOR_ARCHITECTURE is a loader-managed variable; the updated windows-latest runner re-initializes it for spawned processes, so the host's override no longer reached the child — it arrived blank, producing error: Unsupported OS/Arch: windows/ and failing the x86, ARM64, and unknown-version tests. Custom vars such as PROCESSOR_ARCHITEW6432 are unaffected, which is why the WOW64 test kept passing. Setting the vars in the child's own session (after the loader runs) is deterministic across runner images. Empty values Remove-Item the var so "missing PROCESSOR_ARCHITEW6432" detection still works.

This is a test-harness fix only — the shipped install.ps1 and the v0.8.9 binaries are correct; real users always have a populated PROCESSOR_ARCHITECTURE. The v0.8.9 Release workflow (binaries, npm publish, GitHub release) was already green.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Issue for this PR

Closes #958

How did you verify your code works?

  • Diagnosed from CI logs: identical install.ps1 + tests passed on pushes #930 (2026-06-16) and #946 (2026-06-18), then failed on the v0.8.9 push (2026-06-19); a re-run of the failed job reproduced the failure deterministically — isolating the cause to the windows-latest runner image change, not the code.
  • Confirmed the discriminator in the failed run: the WOW64 test (custom var) passed while all three PROCESSOR_ARCHITECTURE-override tests reported a blank arch.
  • No PowerShell available on the dev host, so Pester was not run locally; the change touches test/windows/**, which triggers the Windows Installer (Pester) job, so CI on this PR validates the fix on a real windows-latest runner. All existing test expectations are unchanged.

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by cubic

Stabilizes the Windows Installer (Pester) CI job by injecting PROCESSOR_* env vars inside the child pwsh session and passing args as bareword tokens. Fixes blank arch on updated windows-latest; test harness only, no changes to install.ps1 or shipped binaries. Closes #958.

  • Bug Fixes
    • Uses a pwsh -Command preamble to set/unset env vars only in the child and stops mutating the host env; values are safely single-quote escaped.
    • Ensures PROCESSOR_ARCHITECTURE reaches the child, restoring x86/ARM64 and unknown-version tests; WOW64 path unchanged.
    • Passes test script args as bareword tokens so -Version/-Help bind as parameters, matching -File semantics.

Summary by CodeRabbit

  • Tests
    • Updated the installer test helper to execute installer runs in a dedicated child PowerShell session for improved isolation.
    • Prevented environment variables from being mutated/restored in the parent test process; variables are now applied (or cleared) within the child session.
    • Improved reliability and safety of passing script arguments and injected environment values into the child command, including safer quoting/escaping.