Skip to content

Commit bcffbcb

Browse files
author
Kapil Borle
committed
Fix help tests for PSv3 support
1 parent c471dc6 commit bcffbcb

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

Tests/Engine/ModuleHelp.Tests.ps1

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,18 @@ Get-Module $ModuleName | Remove-Module
212212

213213
# Import the required version
214214
Import-Module $ModuleName -RequiredVersion $RequiredVersion -ErrorAction Stop
215-
$ms = [Microsoft.PowerShell.Commands.ModuleSpecification]@{ ModuleName = $ModuleName; RequiredVersion = $RequiredVersion }
216-
$commands = Get-Command -FullyQualifiedModule $ms -CommandType Cmdlet, Function, Workflow # Not alias
215+
$ms = $null
216+
$commands =$null
217+
$paramBlackList = @()
218+
if ($PSVersionTable.PSVersion -lt [Version]'5.0') {
219+
$ms = New-Object -TypeName 'Microsoft.PowerShell.Commands.ModuleSpecification' -ArgumentList $ModuleName
220+
$commands = Get-Command -Module $ms.Name
221+
$paramBlackList += 'SaveDscDependency'
222+
}
223+
else {
224+
$ms = [Microsoft.PowerShell.Commands.ModuleSpecification]@{ ModuleName = $ModuleName; RequiredVersion = $RequiredVersion }
225+
$commands = Get-Command -FullyQualifiedModule $ms -CommandType Cmdlet,Function,Workflow # Not alias
226+
}
217227

218228
## When testing help, remember that help is cached at the beginning of each session.
219229
## To test, restart session.
@@ -265,6 +275,9 @@ foreach ($command in $commands) {
265275
$HelpParameterNames = $Help.Parameters.Parameter.Name | Sort-Object -Unique
266276

267277
foreach ($parameter in $parameters) {
278+
if ($parameter -in $paramBlackList) {
279+
continue
280+
}
268281
$parameterName = $parameter.Name
269282
$parameterHelp = $Help.parameters.parameter | Where-Object Name -EQ $parameterName
270283

@@ -291,6 +304,9 @@ foreach ($command in $commands) {
291304
}
292305

293306
foreach ($helpParm in $HelpParameterNames) {
307+
if ($helpParm -in $paramBlackList) {
308+
continue
309+
}
294310
# Shouldn't find extra parameters in help.
295311
It "finds help parameter in code: $helpParm" {
296312
$helpParm -in $parameterNames | Should Be $true

0 commit comments

Comments
 (0)