Skip to content

[release/v7.5] Fix a preview detection test for the packaging script#26966

Merged
adityapatwardhan merged 1 commit intoPowerShell:release/v7.5from
adityapatwardhan:backport/release/v7.5/26882-7ca2b72af
Mar 9, 2026
Merged

[release/v7.5] Fix a preview detection test for the packaging script#26966
adityapatwardhan merged 1 commit intoPowerShell:release/v7.5from
adityapatwardhan:backport/release/v7.5/26882-7ca2b72af

Conversation

@adityapatwardhan
Copy link
Member

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

  • Required tooling change
  • Optional tooling change (include reasoning)

Fixes a preview detection test in the packaging script so the build/packaging tooling validates correctly.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

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.

  • High
  • Medium
  • Low

This is a minor test fix in the packaging script with no runtime code changes. Low risk of regression.

Copilot AI review requested due to automatic review settings March 9, 2026 21:26
@adityapatwardhan adityapatwardhan added the CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log label Mar 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
param($Version)
param($Version, $Name)

Copilot uses AI. Check for mistakes.
Comment on lines +49 to 55
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"
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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").

Suggested change
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.

Copilot uses AI. Check for mistakes.
@adityapatwardhan adityapatwardhan merged commit d056f9c into PowerShell:release/v7.5 Mar 9, 2026
39 checks passed
@adityapatwardhan adityapatwardhan deleted the backport/release/v7.5/26882-7ca2b72af branch March 9, 2026 23:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-BuildPackaging Indicates that a PR should be marked as a build or packaging change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants