Skip to content

Commit e9796f9

Browse files
tablackburnclaude
andcommitted
fix(tests): move Pester pin to 6.0.1 and allow empty -ForEach collections
The GitHub-hosted runner images now ship Pester 6.0.1. PSDepend imports the pinned Pester, then PowerShellBuild's Test-PSBuildPester runs `Import-Module Pester -MinimumVersion 5.0.0`, which resolves to the highest installed version and collides with the already-loaded 5.7.1 DLL. Bumping the pin exposes a second, quieter problem. Pester 6 throws on a null/empty -ForEach by default (Run.FailOnNullOrEmptyForEach); Pester 5 quietly generated zero tests. The throw happens during discovery, so Pester fails the entire container (the whole file). A failed container does not increment FailedCount, and Test-PSBuildPester only throws on FailedCount -- so the build passes while that file's tests never run. The affected collections are legitimately empty in a default module: - $helpLinks -- a command declares no http(s) .LINK - $commandParameters -- a command declares only common parameters - $helpParameterNames -- likewise - $dependencies -- RequiredModules is commented out (template default) $commands is deliberately left strict: an empty command list means the module failed to import and should fail loudly. Verified by rendering the template with Initialize-Template.ps1 and running ./build.ps1 -Task Test under Pester 6.0.1: before Tests Passed: 27, containers failed: 2 (Help.tests.ps1, Manifest.tests.ps1) after Tests Passed: 30, containers failed: 0 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015fsEPNYeL5LKdWLDNdv3T6
1 parent d0f1ad8 commit e9796f9

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

build.depend.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
}
99
}
1010
'Pester' = @{
11-
Version = '5.7.1'
11+
Version = '6.0.1'
1212
Parameters = @{
1313
SkipPublisherCheck = $true
1414
}

tests/Help.tests.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
161161
($commandHelp.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty
162162
}
163163

164-
It 'Help link <_> is valid' -ForEach $helpLinks {
164+
It 'Help link <_> is valid' -ForEach $helpLinks -AllowNullOrEmptyForEach {
165165
$currentProgressPreference = $ProgressPreference
166166
$ProgressPreference = 'SilentlyContinue'
167167
$invokeWebRequestParameters = @{
@@ -175,7 +175,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
175175
$statusCode | Should -Be '200'
176176
}
177177

178-
Context 'Parameter <_.Name>' -Foreach $commandParameters {
178+
Context 'Parameter <_.Name>' -Foreach $commandParameters -AllowNullOrEmptyForEach {
179179

180180
BeforeAll {
181181
$parameter = $_
@@ -220,7 +220,7 @@ Describe "Test help for <_.Name>" -ForEach $commands {
220220
}
221221
}
222222

223-
Context 'Test <_> help parameter help for <commandName>' -Foreach $helpParameterNames {
223+
Context 'Test <_> help parameter help for <commandName>' -Foreach $helpParameterNames -AllowNullOrEmptyForEach {
224224

225225
# Shouldn't find extra parameters in help
226226
It 'finds help parameter in code: <_>' {

tests/Manifest.tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ Describe 'Module manifest' {
208208
$changelogVersion -as [Version] | Should -Be ( $manifestData.Version -as [Version] )
209209
}
210210

211-
Context 'Module Dependency' -ForEach $dependencies {
211+
Context 'Module Dependency' -ForEach $dependencies -AllowNullOrEmptyForEach {
212212
# This ensures we keep our dependent modules in sync between the manifest file and the requirements
213213
# script used to bootstrap and test.
214214
BeforeAll {

0 commit comments

Comments
 (0)