diff --git a/test/powershell/Host/ConsoleHost.Tests.ps1 b/test/powershell/Host/ConsoleHost.Tests.ps1 index 542974eb8..404926f47 100644 --- a/test/powershell/Host/ConsoleHost.Tests.ps1 +++ b/test/powershell/Host/ConsoleHost.Tests.ps1 @@ -1190,11 +1190,23 @@ Describe 'Pwsh startup and PATH' -Tag CI { $version | Should -BeExactly "PowerShell $($PSVersionTable.GitCommitId)" } - It 'pwsh starts even if PATH is not defined' { + It 'pwsh updates PATH correctly even if PATH is not defined' { $pwsh = Join-Path -Path $PSHOME -ChildPath "pwsh" Remove-Item Env:\PATH $path = & $pwsh -noprofile -command '$env:PATH' - $path | Should -BeExactly ($PSHOME + [System.IO.Path]::PathSeparator) + + $ExpectedPath = $PSHOME + if ($PSHOME.StartsWith("$env:ProgramFiles\WindowsApps\Microsoft.PowerShell")) { + # MSIX installed PowerShell uses the stable path instead of PSHOME. + $ExpectedPath = $PSHOME.Replace($env:ProgramFiles, "$env:LOCALAPPDATA\Microsoft") + + # Remove the version-specific part from the expected path. + $version = $PSVersionTable.PSVersion + $verStrRegex = "$($version.Major)\.$($version.Minor)\.$($version.Build).+__" + $ExpectedPath = $ExpectedPath -replace $verStrRegex, '' + } + + $path | Should -BeExactly ($ExpectedPath + [System.IO.Path]::PathSeparator) } }