test: Stop skipping the signing tests on Windows PowerShell 5.1 - #199
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #197
The defect
Twenty-two tests across the three signing test files were guarded with
-Skip:(-not $IsWindows).$IsWindowsdoes not exist on Windows PowerShell 5.1, so it is$null,-not $nullis$true, and every one of them skipped — on Windows, on the engine where store-based code signing is most common.Measured under
powershell.exe5.1 before the change:Get-PSBuildCertificate.tests.ps1Invoke-PSBuildModuleSigning.tests.ps1New-PSBuildFileCatalog.tests.ps1After:
Get-PSBuildCertificate.tests.ps1Invoke-PSBuildModuleSigning.tests.ps1New-PSBuildFileCatalog.tests.ps1So #194's
SkipCertificateValidationfallback 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:
"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-ChildItemwith the-CodeSigningCertdynamic 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.ps1andBuild-PSBuildHelp.tests.ps1both use$IsWindows -or $null -eq $IsWindows. Only the signing tests got it inverted.Verification
Analyzeclean.\r\r\n.🤖 Generated with Claude Code
https://claude.ai/code/session_01U1Jhu7fgTRJq7LK5MuKteE