mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix constructing PSModulePath if a sub-path has trailing separator (#13147)
* Fix constructing PSModulePath if a sub-path has trailing separator * skip test on Linux * Removed test as the system env var needs to be modified to repro * Add test * Fix test by comparing against incorrectly created path * Update test to be cross platform
This commit is contained in:
@@ -187,4 +187,18 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||
Remove-Item -Path $userConfigPath -Force
|
||||
}
|
||||
}
|
||||
|
||||
It 'User PSModulePath has trailing separator' {
|
||||
if ($IsWindows) {
|
||||
$validation = "*\$env:SystemDrive\*"
|
||||
}
|
||||
else {
|
||||
$validation = "*//*"
|
||||
}
|
||||
|
||||
$newUserPath = Join-Path $expectedUserPath ([System.IO.Path]::DirectorySeparatorChar)
|
||||
$env:PSModulePath = $env:PSModulePath.Replace($expectedUserPath, $newUserPath).Replace($expectedSharedPath,"")
|
||||
$out = & $powershell -noprofile -command '$env:PSModulePath'
|
||||
$out.Split([System.IO.Path]::PathSeparator, [System.StringSplitOptions]::RemoveEmptyEntries) | Should -Not -BeLike $validation
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user