From c444645b0941d73dc769f0bba6ab70d317bd51a9 Mon Sep 17 00:00:00 2001 From: "James Truher [MSFT]" Date: Mon, 15 May 2023 10:25:12 -0700 Subject: [PATCH] Change how 'isPreview' is determined for default cmdlets tests (#19650) --- test/powershell/engine/Basic/DefaultCommands.Tests.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 index 065f960b0e..6744bf0295 100644 --- a/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 +++ b/test/powershell/engine/Basic/DefaultCommands.Tests.ps1 @@ -18,7 +18,12 @@ Describe "Verify aliases and cmdlets" -Tags "CI" { $FullCLR = !$IsCoreCLR $CoreWindows = $IsCoreCLR -and $IsWindows $CoreUnix = $IsCoreCLR -and !$IsWindows - $isPreview = $PSVersionTable.GitCommitId.Contains("preview") + # If psversion can be converted to [version], then it is not a preview version. + # We can't just use '$psversiontable.psversion -as [version]' because pwsh + # will succeed with the conversion and add note properties to the version object. + $psVersionAsVersion = $psversiontable.psversion.tostring() -as [version] + $isRC = $psversiontable.psversion.tostring() -match "rc" + $isPreview = -not ($isRC -or $psVersionAsVersion) if ($IsWindows) { $configPath = Join-Path -Path $env:USERPROFILE -ChildPath 'Documents' -AdditionalChildPath 'PowerShell' }