2016-07-26 02:43:28 +02:00
|
|
|
Describe "Configuration file locations" -tags "CI","Slow" {
|
2016-06-09 19:41:30 +02:00
|
|
|
|
|
|
|
BeforeAll {
|
|
|
|
$powershell = Join-Path -Path $PsHome -ChildPath "powershell"
|
|
|
|
$profileName = "Microsoft.PowerShell_profile.ps1"
|
|
|
|
}
|
|
|
|
|
|
|
|
Context "Default configuration file locations" {
|
|
|
|
|
|
|
|
BeforeAll {
|
|
|
|
|
|
|
|
if ($IsWindows) {
|
2016-08-12 02:59:04 +02:00
|
|
|
$ProductName = "WindowsPowerShell"
|
|
|
|
if ($IsCoreCLR -and ($PSHOME -notlike "*Windows\System32\WindowsPowerShell\v1.0"))
|
|
|
|
{
|
|
|
|
$ProductName = "PowerShell"
|
|
|
|
}
|
2016-06-09 19:41:30 +02:00
|
|
|
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
|
2016-08-12 02:59:04 +02:00
|
|
|
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", $ProductName, "Modules")
|
|
|
|
$expectedProfile = [io.path]::Combine($env:USERPROFILE, "Documents", $ProductName, $profileName)
|
2016-06-09 19:41:30 +02:00
|
|
|
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
|
|
|
|
} else {
|
|
|
|
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
|
|
|
|
$expectedModule = [IO.Path]::Combine($env:HOME, ".local", "share", "powershell", "Modules")
|
|
|
|
$expectedProfile = [io.path]::Combine($env:HOME,".config","powershell",$profileName)
|
|
|
|
$expectedReadline = [IO.Path]::Combine($env:HOME, ".local", "share", "powershell", "PSReadLine", "ConsoleHost_history.txt")
|
|
|
|
}
|
|
|
|
|
2016-06-29 23:23:15 +02:00
|
|
|
$ItArgs = @{}
|
2016-06-09 19:41:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
BeforeEach {
|
2017-03-15 20:04:28 +01:00
|
|
|
$original_PSModulePath = $env:PSModulePath
|
2016-06-09 19:41:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
AfterEach {
|
2017-03-15 20:04:28 +01:00
|
|
|
$env:PSModulePath = $original_PSModulePath
|
2016-06-09 19:41:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
It @ItArgs "Profile location should be correct" {
|
2017-06-22 03:47:56 +02:00
|
|
|
& $powershell -noprofile -c `$PROFILE | Should Be $expectedProfile
|
2016-06-09 19:41:30 +02:00
|
|
|
}
|
|
|
|
|
2017-03-15 20:04:28 +01:00
|
|
|
It @ItArgs "PSModulePath should contain the correct path" {
|
|
|
|
$env:PSModulePath = ""
|
2017-06-22 03:47:56 +02:00
|
|
|
$actual = & $powershell -noprofile -c `$env:PSModulePath
|
2016-06-09 19:41:30 +02:00
|
|
|
$actual | Should Match ([regex]::Escape($expectedModule))
|
|
|
|
}
|
|
|
|
|
|
|
|
It @ItArgs "PSReadLine history save location should be correct" {
|
|
|
|
& $powershell -noprofile { (Get-PSReadlineOption).HistorySavePath } | Should Be $expectedReadline
|
|
|
|
}
|
|
|
|
|
2016-06-29 04:33:31 +02:00
|
|
|
# This feature (and thus test) has been disabled because of the AssemblyLoadContext scenario
|
|
|
|
It "JIT cache should be created correctly" -Skip {
|
2016-06-09 19:41:30 +02:00
|
|
|
Remove-Item -ErrorAction SilentlyContinue $expectedCache
|
|
|
|
& $powershell -noprofile { exit }
|
|
|
|
$expectedCache | Should Exist
|
|
|
|
}
|
|
|
|
|
|
|
|
# The ModuleAnalysisCache cannot be forced to exist, thus we cannot test it
|
|
|
|
}
|
|
|
|
|
|
|
|
Context "XDG Base Directory Specification is supported on Linux" {
|
|
|
|
BeforeAll {
|
|
|
|
# Using It @ItArgs, we automatically skip on Windows for all these tests
|
|
|
|
if ($IsWindows) {
|
|
|
|
$ItArgs = @{ skip = $true }
|
|
|
|
} else {
|
|
|
|
$ItArgs = @{}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BeforeEach {
|
2017-03-15 20:04:28 +01:00
|
|
|
$original_PSModulePath = $env:PSModulePath
|
2016-06-09 19:41:30 +02:00
|
|
|
$original_XDG_CONFIG_HOME = $env:XDG_CONFIG_HOME
|
|
|
|
$original_XDG_CACHE_HOME = $env:XDG_CACHE_HOME
|
|
|
|
$original_XDG_DATA_HOME = $env:XDG_DATA_HOME
|
|
|
|
}
|
|
|
|
|
|
|
|
AfterEach {
|
2017-03-15 20:04:28 +01:00
|
|
|
$env:PSModulePath = $original_PSModulePath
|
2016-06-09 19:41:30 +02:00
|
|
|
$env:XDG_CONFIG_HOME = $original_XDG_CONFIG_HOME
|
|
|
|
$env:XDG_CACHE_HOME = $original_XDG_CACHE_HOME
|
|
|
|
$env:XDG_DATA_HOME = $original_XDG_DATA_HOME
|
|
|
|
}
|
|
|
|
|
|
|
|
It @ItArgs "Profile should respect XDG_CONFIG_HOME" {
|
|
|
|
$env:XDG_CONFIG_HOME = $TestDrive
|
|
|
|
$expected = [IO.Path]::Combine($TestDrive, "powershell", $profileName)
|
2017-06-22 22:35:04 +02:00
|
|
|
& $powershell -noprofile -c `$PROFILE | Should Be $expected
|
2016-06-09 19:41:30 +02:00
|
|
|
}
|
|
|
|
|
2017-03-15 20:04:28 +01:00
|
|
|
It @ItArgs "PSModulePath should respect XDG_DATA_HOME" {
|
|
|
|
$env:PSModulePath = ""
|
2016-06-09 19:41:30 +02:00
|
|
|
$env:XDG_DATA_HOME = $TestDrive
|
|
|
|
$expected = [IO.Path]::Combine($TestDrive, "powershell", "Modules")
|
2017-06-22 22:35:04 +02:00
|
|
|
$actual = & $powershell -noprofile -c `$env:PSModulePath
|
2016-06-09 19:41:30 +02:00
|
|
|
$actual | Should Match $expected
|
|
|
|
}
|
|
|
|
|
|
|
|
It @ItArgs "PSReadLine history should respect XDG_DATA_HOME" {
|
|
|
|
$env:XDG_DATA_HOME = $TestDrive
|
|
|
|
$expected = [IO.Path]::Combine($TestDrive, "powershell", "PSReadLine", "ConsoleHost_history.txt")
|
|
|
|
& $powershell -noprofile { (Get-PSReadlineOption).HistorySavePath } | Should Be $expected
|
|
|
|
}
|
|
|
|
|
2016-06-29 04:33:31 +02:00
|
|
|
# This feature (and thus test) has been disabled because of the AssemblyLoadContext scenario
|
|
|
|
It -Skip "JIT cache should respect XDG_CACHE_HOME" {
|
2016-06-09 19:41:30 +02:00
|
|
|
$env:XDG_CACHE_HOME = $TestDrive
|
|
|
|
$expected = [IO.Path]::Combine($TestDrive, "powershell", "StartupProfileData-NonInteractive")
|
|
|
|
Remove-Item -ErrorAction SilentlyContinue $expected
|
|
|
|
& $powershell -noprofile { exit }
|
|
|
|
$expected | Should Exist
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|