[release/v7.5] Fix a preview detection test for the packaging script#26966
Conversation
There was a problem hiding this comment.
Pull request overview
Backport to release/v7.5 that adjusts the packaging Pester tests intended to validate preview detection logic used by the macOS packaging identifier helper.
Changes:
- Converts the “package name not used for preview detection” test into a data-driven test with two version cases (preview + rc).
- Removes the explicit “incorrect package-name-based check” demonstration from the test body.
| $incorrectCheck = $Name -like '*-preview' | ||
| $incorrectCheck | Should -Be $false -Because "Package name is 'powershell' not 'powershell-preview'" | ||
|
|
||
| param($Version) |
There was a problem hiding this comment.
This It block defines param($Version) but the -TestCases hashtables also include a Name key. Pester passes test-case keys as named arguments to the scriptblock, so the extra Name entry will cause a parameter binding error. Add $Name to the param block (even if unused) or remove the Name key from the test cases / title placeholder.
| param($Version) | |
| param($Version, $Name) |
| It "Should NOT use package name for preview detection (bug fix verification) - <Name>" -TestCases @( | ||
| @{ Version = "7.6.0-preview.6"; Name = "Preview" } | ||
| @{ Version = "7.6.0-rc.1"; Name = "RC" } | ||
| ) { | ||
| # This test verifies the fix for issue #26673 | ||
| # The bug was using ($Name -like '*-preview') which always returned false | ||
| # because preview builds use Name="powershell" not "powershell-preview" |
There was a problem hiding this comment.
The test name/comment says it verifies that preview detection does not use the package name, but the updated test cases use Name = "Preview"/"RC" only as a label and no longer demonstrate the failing package-name-based logic described in the comments. Either update the test description/comments to match what is actually being asserted (preview detection from version string), or reintroduce an assertion that shows the package-name check would fail (using a realistic package name like "powershell").
| It "Should NOT use package name for preview detection (bug fix verification) - <Name>" -TestCases @( | |
| @{ Version = "7.6.0-preview.6"; Name = "Preview" } | |
| @{ Version = "7.6.0-rc.1"; Name = "RC" } | |
| ) { | |
| # This test verifies the fix for issue #26673 | |
| # The bug was using ($Name -like '*-preview') which always returned false | |
| # because preview builds use Name="powershell" not "powershell-preview" | |
| It "Should detect preview builds based on version string (bug fix verification) - <Name>" -TestCases @( | |
| @{ Version = "7.6.0-preview.6"; Name = "Preview" } | |
| @{ Version = "7.6.0-rc.1"; Name = "RC" } | |
| ) { | |
| # This test verifies the fix for issue #26673. | |
| # The fix ensures preview detection relies on the version string (e.g. '-preview', '-rc') | |
| # rather than any package name convention. |
Backport of #26882 to release/v7.5
Triggered by @adityapatwardhan on behalf of @daxian-dbw
Original CL Label: CL-BuildPackaging
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Fixes a preview detection test in the packaging script so the build/packaging tooling validates correctly.
Customer Impact
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Existing tests in the packaging script cover preview detection. The fix corrects a test condition; no additional tests are needed.
Risk
REQUIRED: Check exactly one box.
This is a minor test fix in the packaging script with no runtime code changes. Low risk of regression.