mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Address review comments in test code
This commit is contained in:
1 parent
ea9694980e
commit
401b6194da
2 files changed
+40
-22
No files matched your search
@@ -10,9 +10,14 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
|||||||
BeforeAll {
|
BeforeAll {
|
||||||
|
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
|
$ProductName = "WindowsPowerShell"
|
||||||
|
if ($IsCoreCLR -and ($PSHOME -notlike "*Windows\System32\WindowsPowerShell\v1.0"))
|
||||||
|
{
|
||||||
|
$ProductName = "PowerShell"
|
||||||
|
}
|
||||||
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
|
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
|
||||||
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", "PowerShell", "Modules")
|
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", $ProductName, "Modules")
|
||||||
$expectedProfile = [io.path]::Combine($env:USERPROFILE, "Documents","PowerShell",$profileName)
|
$expectedProfile = [io.path]::Combine($env:USERPROFILE, "Documents", $ProductName, $profileName)
|
||||||
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
|
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
|
||||||
} else {
|
} else {
|
||||||
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
|
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
|
||||||
|
|||||||
@@ -1,32 +1,45 @@
|
|||||||
Describe "Module Path Basic Tests" -tags "CI" {
|
Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||||
|
|
||||||
It "validate module path on windows" -Skip:(!$IsWindows) {
|
BeforeAll {
|
||||||
|
|
||||||
$paths = $env:PSMODULEPATH -split [System.IO.Path]::PathSeparator
|
|
||||||
$paths.Count | Should Be 3
|
|
||||||
|
|
||||||
$expectedUserPath = Join-Path -Path $HOME -ChildPath 'Documents\PowerShell\Modules'
|
|
||||||
$paths[0] | Should Be $expectedUserPath
|
|
||||||
|
|
||||||
$expectedSharedPath = Join-Path -Path $env:ProgramFiles -ChildPath 'PowerShell\Modules'
|
|
||||||
$paths[1] | Should Be $expectedSharedPath
|
|
||||||
|
|
||||||
|
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'
|
$expectedSystemPath = Join-Path -Path $PSHOME -ChildPath 'Modules'
|
||||||
$paths[2] | Should Be $expectedSystemPath
|
|
||||||
}
|
}
|
||||||
|
|
||||||
It "validate module path on unix" -Skip:($IsWindows) {
|
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 = $env:PSMODULEPATH -split [System.IO.Path]::PathSeparator
|
|
||||||
$paths.Count | Should Be 3
|
$paths.Count | Should Be 3
|
||||||
|
|
||||||
$expectedUserPath = [System.Management.Automation.Platform]::SelectProductNameForDirectory("USER_MODULES")
|
|
||||||
$paths[0] | Should Be $expectedUserPath
|
$paths[0] | Should Be $expectedUserPath
|
||||||
|
|
||||||
$expectedSharedPath = [System.Management.Automation.Platform]::SelectProductNameForDirectory("SHARED_MODULES")
|
|
||||||
$paths[1] | Should Be $expectedSharedPath
|
$paths[1] | Should Be $expectedSharedPath
|
||||||
|
|
||||||
$expectedSystemPath = Join-Path -Path $PSHOME -ChildPath 'Modules'
|
|
||||||
$paths[2] | Should Be $expectedSystemPath
|
$paths[2] | Should Be $expectedSystemPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user