Skip to content

test: Stop skipping the signing tests on Windows PowerShell 5.1 - #199

Merged
tablackburn merged 1 commit into
mainfrom
bugfix/197-skip-guard-5.1
Aug 28, 2026
Merged

test: Stop skipping the signing tests on Windows PowerShell 5.1#199
tablackburn merged 1 commit into
mainfrom
bugfix/197-skip-guard-5.1

Conversation

@tablackburn

Copy link
Copy Markdown
Contributor

Closes #197

The defect

Twenty-two tests across the three signing test files were guarded with -Skip:(-not $IsWindows). $IsWindows does not exist on Windows PowerShell 5.1, so it is $null, -not $null is $true, and every one of them skipped — on Windows, on the engine where store-based code signing is most common.

Measured under powershell.exe 5.1 before the change:

File passed skipped
Get-PSBuildCertificate.tests.ps1 8 18
Invoke-PSBuildModuleSigning.tests.ps1 9 2
New-PSBuildFileCatalog.tests.ps1 8 2

After:

File passed skipped
Get-PSBuildCertificate.tests.ps1 26 0
Invoke-PSBuildModuleSigning.tests.ps1 11 0
New-PSBuildFileCatalog.tests.ps1 10 0

So #194's SkipCertificateValidation fallback had never once been exercised on 5.1 in CI.

The fix

The guard is now the shape the product code already uses — twelve lines from one of these call sites:

# $IsWindows does not exist on Windows PowerShell 5.1 (Desktop edition), where it is $null
# and the platform is always Windows; only treat the platform as non-Windows when $IsWindows
# is explicitly $false (PowerShell 7+ on Linux/macOS).
if ($null -ne $IsWindows -and -not $IsWindows) {

"Windows-only" meant platform, not edition — the comment justifying the guard said exactly that while the guard itself did not. That comment now also records why the shape matters, so the next person does not reintroduce the short form.

The risk that didn't materialise

This was filed rather than fixed inline because the mocks might have behaved differently on the older engine — Mock -ModuleName PowerShellBuild -CommandName Get-ChildItem with the -CodeSigningCert dynamic parameter — so un-skipping could have surfaced failures in the tests rather than the code.

It didn't. All twenty-two pass on 5.1 unchanged, no test bodies touched.

Wider than reported

The issue described this as the convention within one file. It was three — the other two signing test files carried the same inverted guard and are corrected here. grep -rn '\-not \$IsWindows' tests/ now returns nothing outside the corrected form.

Worth noting the repo already had the right pattern elsewhere: build.tests.ps1 and Build-PSBuildHelp.tests.ps1 both use $IsWindows -or $null -eq $IsWindows. Only the signing tests got it inverted.

Verification

  • PowerShell 7 full suite: 503 passed, 0 failed, 3 skipped; Analyze clean.
  • Windows PowerShell 5.1: the three files run 47 tests, 0 failed, 0 skipped.
  • All three files verified CRLF-only, no lone LF, no \r\r\n.

🤖 Generated with Claude Code

https://claude.ai/code/session_01U1Jhu7fgTRJq7LK5MuKteE

Twenty-two tests across the three signing test files were guarded with
-Skip:(-not $IsWindows). $IsWindows does not exist on Windows PowerShell
5.1, so it evaluates to $null, -not $null is $true, and every one of them
skipped -- on Windows, on the engine where store-based code signing is
most common.

Measured before the change, under powershell.exe 5.1:

  Get-PSBuildCertificate      passed=8  failed=0 skipped=18
  Invoke-PSBuildModuleSigning          skipped=2
  New-PSBuildFileCatalog               skipped=2

After:

  Get-PSBuildCertificate      passed=26 failed=0 skipped=0
  Invoke-PSBuildModuleSigning passed=11 failed=0 skipped=0
  New-PSBuildFileCatalog      passed=10 failed=0 skipped=0

The guard is now the shape the product code already uses twelve lines from
one of these call sites: treat the platform as non-Windows only when
$IsWindows is explicitly $false. Windows-only meant platform, not edition,
and the comment justifying the guard said so while the guard itself did
not.

The concern that motivated filing this rather than fixing it inline --
that the mocks might behave differently on the older engine, so
un-skipping could surface failures in the tests rather than the code --
did not materialise. All twenty-two pass on 5.1 unchanged.

The issue described this as the convention within one file. It was three:
the other two signing test files carried the same inverted guard, and are
corrected here too. No inverted guard remains in tests/.

Closes #197

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U1Jhu7fgTRJq7LK5MuKteE
Copilot AI lite review requested due to automatic review settings August 28, 2026 02:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

Test Results

    4 files  ±0    785 suites  ±0   2m 26s ⏱️ +12s
  508 tests ±0    505 ✅ ± 0   3 💤 ± 0  0 ❌ ±0 
2 015 runs  ±0  1 943 ✅ +22  72 💤  - 22  0 ❌ ±0 

Results for commit 3bdb642. ± Comparison against base commit ff45f77.

@tablackburn
tablackburn merged commit a4fa998 into main Aug 28, 2026
9 checks passed
@tablackburn
tablackburn deleted the bugfix/197-skip-guard-5.1 branch August 28, 2026 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Store and Thumbprint certificate tests never run on Windows PowerShell 5.1

2 participants