devblackops / Stucco

An opinionated Plaster template for high-quality PowerShell modules
MIT License
196 stars 27 forks source link

help test errors with PowerShell 7.4 #41

Open gazm81 opened 9 months ago

gazm81 commented 9 months ago

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,

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

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