mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-13 21:32:06 +00:00
Fix the PATH test for MSIX installed PowerShell (#28068)
This commit is contained in:
1 parent
78c98a120a
commit
5f9fcddc28
1 file changed
+14
-2
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user