Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions test/packaging/macos/package-validation.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ Describe "Verify macOS Package" {
$script:package | Should -Not -BeNullOrEmpty

# Regex pattern for valid macOS PKG package names.
# This pattern matches the validation used in release-validate-packagenames.yml
# Valid examples:
# - powershell-7.4.13-osx-x64.pkg (Intel x64 - note: x64 with hyphens for compatibility)
# - powershell-7.4.13-osx-arm64.pkg (Apple Silicon)
# - powershell-preview-7.6.0-preview.6-osx-x64.pkg
# - powershell-lts-7.4.13-osx-arm64.pkg
$pkgPackageNamePattern = '^powershell(-preview|-lts)?-\d+\.\d+\.\d+(-[a-z]+\.\d+)?-osx-(x64|arm64)\.pkg$'
# - powershell-7.4.13-osx-x64.pkg (Stable release)
# - powershell-7.6.0-preview.6-osx-x64.pkg (Preview version string)
# - powershell-7.4.13-rebuild.5-osx-arm64.pkg (Rebuild version)
# - powershell-lts-7.4.13-osx-arm64.pkg (LTS package)
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg$'
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The regex pattern has an unescaped dot in the preview/rebuild version capture group ([a-z]*.\d+\-)?. The dot should be escaped as \. to match a literal dot character, not any character.

Current: ([a-z]*.\d+\-)?
Should be: ([a-z]*\.\d+\-)?

Without escaping, the pattern would incorrectly match strings like "preview6" or "previewX6" instead of only matching "preview.6".

Suggested change
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg$'
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*\.\d+\-)?osx\-(x64|arm64)\.pkg$'

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Dec 5, 2025

Choose a reason for hiding this comment

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

The preview/rebuild version capture group uses [a-z]* which allows zero or more letters, making the entire prerelease identifier optional even when present. This would incorrectly match malformed names like "7.6.0-.6-osx-x64.pkg" (missing the word before the dot).

Current: ([a-z]*\.\d+\-)?
Should be: ([a-z]+\.\d+\-)?

Using [a-z]+ (one or more) ensures that if a prerelease identifier is present, it must have at least one letter before the dot.

Suggested change
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]*.\d+\-)?osx\-(x64|arm64)\.pkg$'
$pkgPackageNamePattern = '^powershell-(lts-)?\d+\.\d+\.\d+\-([a-z]+\.\d+\-)?osx\-(x64|arm64)\.pkg$'

Copilot uses AI. Check for mistakes.

$script:package.Name | Should -Match $pkgPackageNamePattern -Because "Package name should follow the standard naming convention"
}
Expand Down Expand Up @@ -182,4 +183,4 @@ Describe "Verify macOS Package" {
}
}
}
}
}