Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help test errors with PowerShell 7.4 #41

Open
gazm81 opened this issue Feb 1, 2024 · 0 comments
Open

help test errors with PowerShell 7.4 #41

gazm81 opened this issue Feb 1, 2024 · 0 comments

Comments

@gazm81
Copy link
Contributor

gazm81 commented Feb 1, 2024

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

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

No branches or pull requests

1 participant