mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Merge pull request #1721 from PowerShell/dongbo/module-path
Address the side-by-side module path for OPS
This commit is contained in:
commit
539c59cc35
23 files changed
+508
-294
No files matched your search
@@ -0,0 +1,45 @@
|
||||
Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||
|
||||
BeforeAll {
|
||||
|
||||
if ($IsWindows)
|
||||
{
|
||||
$powershell = "$PSHOME\powershell.exe"
|
||||
$ProductName = "WindowsPowerShell"
|
||||
if ($IsCoreCLR -and ($PSHOME -notlike "*Windows\System32\WindowsPowerShell\v1.0"))
|
||||
{
|
||||
$ProductName = "PowerShell"
|
||||
}
|
||||
$expectedUserPath = Join-Path -Path $HOME -ChildPath "Documents\$ProductName\Modules"
|
||||
$expectedSharedPath = Join-Path -Path $env:ProgramFiles -ChildPath "$ProductName\Modules"
|
||||
}
|
||||
else
|
||||
{
|
||||
$powershell = "$PSHOME/powershell"
|
||||
$expectedUserPath = [System.Management.Automation.Platform]::SelectProductNameForDirectory("USER_MODULES")
|
||||
$expectedSharedPath = [System.Management.Automation.Platform]::SelectProductNameForDirectory("SHARED_MODULES")
|
||||
}
|
||||
$expectedSystemPath = Join-Path -Path $PSHOME -ChildPath 'Modules'
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$originalModulePath = $env:PSMODULEPATH
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
$env:PSMODULEPATH = $originalModulePath
|
||||
}
|
||||
|
||||
It "validate sxs module path" {
|
||||
|
||||
$env:PSMODULEPATH = ""
|
||||
$defaultModulePath = & $powershell -nopro -c '$env:PSMODULEPATH'
|
||||
|
||||
$paths = $defaultModulePath -split [System.IO.Path]::PathSeparator
|
||||
|
||||
$paths.Count | Should Be 3
|
||||
$paths[0] | Should Be $expectedUserPath
|
||||
$paths[1] | Should Be $expectedSharedPath
|
||||
$paths[2] | Should Be $expectedSystemPath
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user