Skip to content

help test errors with PowerShell 7.4 #41

@gazm81

Description

@gazm81

Description

When using powershell 7.4 (7.3.X and earlier fine)
The Tests in Help.tsts.ps1 now fails due to an additional  common parameter in PowerShell 7.4.
The Help.Tsts.ps1 attempts to filter out common params through a hard coded list but that is now missing one,
specifically "ProgressAction"

On development workstations this will occur when the local runtime is bumped to 7.4, however, it will also with the devcontainer due to powershell:latest being called, which now brings 7.4

Steps to Reproduce
Merely update the powershell runtime to PowerShell 7.4.1 or later (i haven't tested 7.4.0), and run the regular build file.
you will get a series of errors showing that the parameter ProgressAction doesn't have help description or type.

Additionally just run the normal tests from the default devcontainer.

Current Behavior
help.tsts.ps1 returns some incorrect pester fails.

Expected behavior
help.tsts.ps1 doesn't validate common params

Possible Solution
2 solutions considered,

  • update help.tsts.ps1 static list of common params with the new param
  • update help.tsts.ps1 static list of common params with dynamic list of common and optional params
    theoretically, either will work for now, but the dynamic option will be more resilient to future changes to Powershell.
    PR coming with recommended solution of dynamic list.

original code (doesn't work on 7.4.X)

        $commonParams = @(
            'Debug', 'ErrorAction', 'ErrorVariable', 'InformationAction', 'InformationVariable',
            'OutBuffer', 'OutVariable', 'PipelineVariable', 'Verbose', 'WarningAction',
            'WarningVariable', 'Confirm', 'Whatif'
        )

amended dynamic code (works on 7.X)(tested on 7.2 7.3 and 7.4)

        $commonParams = [System.Management.Automation.PSCmdlet]::OptionalCommonParameters + [System.Management.Automation.PSCmdlet]::CommonParameters

Screenshots
image

Environment

  • Module version used: 0.4.0 0.5.0 and master
  • Operating System and PowerShell version: ubuntu 20.04 - Ubuntu 22.04 and Windows 11, Powershell Versions 7.2 7.3 7.4

Additional context
we have a series of internal powershell modules that use the testing provided in help.tsts.ps1
the automated tests that run on our various agents cause these tests to fail if the powershell version is 7.4
while we can control the agent PS version, this is getting in the way of some development work where we have less control over the specific powershell versions. additionally the default devcontainer runs with powershell:latest , causing this model to fail as well

the fix proposed won't fix our prior deployed modules we will need to amend them, however it will prevent future modules experiencing the same issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions