mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
corrected use of PSModulePath casing to be consistent with Windows PowerShell (#3255)
* corrected use of PSModulePath casing to be consistent with Windows PowerShell addresses #3227 * addressing review feedback make "PSModulePath" into const fixed some test workarounds due to failures for external reasons that wasn't meant to be checked in * addressing review feedback make "PSModulePath" into const fixed some test workarounds due to failures for external reasons that wasn't meant to be checked in
This commit is contained in:
@@ -90,7 +90,7 @@ PowerShell accepts both `-` and `--` prefixed arguments.
|
||||
|
||||
These are environment variables used by PowerShell.
|
||||
|
||||
* `$PSMODULEPATH`:
|
||||
* `$PSModulePath`:
|
||||
A colon (`:`) separated load path for PowerShell modules.
|
||||
|
||||
## AUTOMATIC VARIABLES
|
||||
|
||||
+3
-3
@@ -771,7 +771,7 @@ function Start-PSPester {
|
||||
}
|
||||
else {
|
||||
try {
|
||||
$originalModulePath = $env:PSMODULEPATH
|
||||
$originalModulePath = $env:PSModulePath
|
||||
if ($Unelevate)
|
||||
{
|
||||
Start-UnelevatedProcess -process $powershell -arguments @('-noprofile', '-c', $Command)
|
||||
@@ -801,7 +801,7 @@ function Start-PSPester {
|
||||
& $powershell -noprofile -c $Command
|
||||
}
|
||||
} finally {
|
||||
$env:PSMODULEPATH = $originalModulePath
|
||||
$env:PSModulePath = $originalModulePath
|
||||
if ($Unelevate)
|
||||
{
|
||||
Remove-Item $outputBufferFilePath
|
||||
@@ -1784,7 +1784,7 @@ function Start-DevPowerShell {
|
||||
if (-not $Command) {
|
||||
$ArgumentList = @('-NoExit') + $ArgumentList
|
||||
}
|
||||
$Command = '$env:PSMODULEPATH = Join-Path $env:DEVPATH Modules; ' + $Command
|
||||
$Command = '$env:PSModulePath = Join-Path $env:DEVPATH Modules; ' + $Command
|
||||
}
|
||||
|
||||
if ($Command) {
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
###
|
||||
### Install-Package -Name AzureRM.NetCore.Preview -Source https://www.powershellgallery.com/api/v2 -ProviderName NuGet -ExcludeVersion -Destination <Folder you want this to be installed>
|
||||
###
|
||||
### Ensure $env:PSMODULEPATH is updated with the location you used to install.
|
||||
### Ensure $env:PSModulePath is updated with the location you used to install.
|
||||
Import-Module AzureRM.NetCore.Preview
|
||||
|
||||
### Supply your Azure Credentials
|
||||
|
||||
@@ -110,7 +110,7 @@ This build/restore process should work anywhere .NET Core works, including Windo
|
||||
Deployment
|
||||
----------
|
||||
|
||||
In PowerShell, check `$env:PSMODULEPATH` and install the new cmdlet in its own
|
||||
In PowerShell, check `$env:PSModulePath` and install the new cmdlet in its own
|
||||
module folder, such as, on Linux,
|
||||
`~/.powershell/Modules/SendGreeting/SendGreeting.dll`.
|
||||
|
||||
|
||||
@@ -3933,7 +3933,7 @@ namespace Microsoft.PowerShell.Workflow
|
||||
}
|
||||
else
|
||||
{
|
||||
continue; // Something like $env:psmodulepath
|
||||
continue; // Something like $env:PSModulePath
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -14,6 +14,11 @@ using Dbg = System.Management.Automation.Diagnostics;
|
||||
|
||||
namespace System.Management.Automation
|
||||
{
|
||||
internal static class Constants
|
||||
{
|
||||
public const string PSModulePathEnvVar = "PSModulePath";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encapsulates the basic module operations for a PowerShell engine instance...
|
||||
/// </summary>
|
||||
@@ -710,7 +715,7 @@ namespace System.Management.Automation
|
||||
|
||||
/// <summary>
|
||||
/// Check if the current powershell is likely running in following scenarios:
|
||||
/// - sxs ps started on windows [machine-wide env:psmodulepath will influence]
|
||||
/// - sxs ps started on windows [machine-wide env:PSModulePath will influence]
|
||||
/// - sxs ps started from full ps
|
||||
/// - sxs ps started from inbox nano/iot ps
|
||||
/// - full ps started from sxs ps
|
||||
@@ -734,8 +739,8 @@ namespace System.Management.Automation
|
||||
// so if the current process module path contains any of them, it's likely that the sxs
|
||||
// ps was started directly on windows, or from full ps. The same goes for the legacy personal
|
||||
// and shared module paths.
|
||||
string hklmModulePath = GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.Machine);
|
||||
string hkcuModulePath = GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.User);
|
||||
string hklmModulePath = GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.Machine);
|
||||
string hkcuModulePath = GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.User);
|
||||
string legacyPersonalModulePath = personalModulePath.Replace(winSxSModuleDirectory, winLegacyModuleDirectory);
|
||||
string legacyProgramFilesModulePath = sharedModulePath.Replace(winSxSModuleDirectory, winLegacyModuleDirectory);
|
||||
|
||||
@@ -824,7 +829,7 @@ namespace System.Management.Automation
|
||||
NeedToClearProcessModulePath(currentProcessModulePath, personalModulePath, sharedModulePath, runningSxS))
|
||||
{
|
||||
// Clear the current process module path in the following cases
|
||||
// - start sxs ps on windows [machine-wide env:psmodulepath will influence]
|
||||
// - start sxs ps on windows [machine-wide env:PSModulePath will influence]
|
||||
// - start sxs ps from full ps
|
||||
// - start sxs ps from inbox nano/iot ps
|
||||
// - start full ps from sxs ps
|
||||
@@ -971,7 +976,7 @@ namespace System.Management.Automation
|
||||
/// </summary>
|
||||
internal static string GetModulePath()
|
||||
{
|
||||
string currentModulePath = GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.Process);
|
||||
string currentModulePath = GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.Process);
|
||||
return currentModulePath;
|
||||
}
|
||||
/// <summary>
|
||||
@@ -981,7 +986,7 @@ namespace System.Management.Automation
|
||||
/// </summary>
|
||||
internal static string SetModulePath()
|
||||
{
|
||||
string currentModulePath = GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.Process);
|
||||
string currentModulePath = GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.Process);
|
||||
string systemWideModulePath = ConfigPropertyAccessor.Instance.GetModulePath(ConfigPropertyAccessor.PropertyScope.SystemWide);
|
||||
string personalModulePath = ConfigPropertyAccessor.Instance.GetModulePath(ConfigPropertyAccessor.PropertyScope.CurrentUser);
|
||||
|
||||
@@ -990,7 +995,7 @@ namespace System.Management.Automation
|
||||
if (!string.IsNullOrEmpty(newModulePathString))
|
||||
{
|
||||
// Set the environment variable...
|
||||
Environment.SetEnvironmentVariable("PSMODULEPATH", newModulePathString);
|
||||
Environment.SetEnvironmentVariable(Constants.PSModulePathEnvVar, newModulePathString);
|
||||
}
|
||||
|
||||
return newModulePathString;
|
||||
@@ -1013,7 +1018,7 @@ namespace System.Management.Automation
|
||||
/// <returns>The module path as an array of strings</returns>
|
||||
internal static IEnumerable<string> GetModulePath(bool includeSystemModulePath, ExecutionContext context)
|
||||
{
|
||||
string modulePathString = Environment.GetEnvironmentVariable("PSMODULEPATH") ?? SetModulePath();
|
||||
string modulePathString = Environment.GetEnvironmentVariable(Constants.PSModulePathEnvVar) ?? SetModulePath();
|
||||
|
||||
HashSet<string> processedPathSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
|
||||
@@ -169,7 +169,7 @@ namespace System.Management.Automation
|
||||
|
||||
string fileName = Path.Combine(scopeDirectory, configFileName);
|
||||
|
||||
string modulePath = ReadValueFromFile<string>(fileName, "PsModulePath");
|
||||
string modulePath = ReadValueFromFile<string>(fileName, Constants.PSModulePathEnvVar);
|
||||
if (!string.IsNullOrEmpty(modulePath))
|
||||
{
|
||||
modulePath = Environment.ExpandEnvironmentVariables(modulePath);
|
||||
@@ -518,11 +518,11 @@ namespace System.Management.Automation
|
||||
{
|
||||
if (PropertyScope.CurrentUser == scope)
|
||||
{
|
||||
return ModuleIntrinsics.GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.User);
|
||||
return ModuleIntrinsics.GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.User);
|
||||
}
|
||||
else
|
||||
{
|
||||
return ModuleIntrinsics.GetExpandedEnvironmentVariable("PSMODULEPATH", EnvironmentVariableTarget.Machine);
|
||||
return ModuleIntrinsics.GetExpandedEnvironmentVariable(Constants.PSModulePathEnvVar, EnvironmentVariableTarget.Machine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,20 +30,20 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$original_PSMODULEPATH = $env:PSMODULEPATH
|
||||
$original_PSModulePath = $env:PSModulePath
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
$env:PSMODULEPATH = $original_PSMODULEPATH
|
||||
$env:PSModulePath = $original_PSModulePath
|
||||
}
|
||||
|
||||
It @ItArgs "Profile location should be correct" {
|
||||
& $powershell -noprofile `$PROFILE | Should Be $expectedProfile
|
||||
}
|
||||
|
||||
It @ItArgs "PSMODULEPATH should contain the correct path" {
|
||||
$env:PSMODULEPATH = ""
|
||||
$actual = & $powershell -noprofile `$env:PSMODULEPATH
|
||||
It @ItArgs "PSModulePath should contain the correct path" {
|
||||
$env:PSModulePath = ""
|
||||
$actual = & $powershell -noprofile `$env:PSModulePath
|
||||
$actual | Should Match ([regex]::Escape($expectedModule))
|
||||
}
|
||||
|
||||
@@ -72,14 +72,14 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$original_PSMODULEPATH = $env:PSMODULEPATH
|
||||
$original_PSModulePath = $env:PSModulePath
|
||||
$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 {
|
||||
$env:PSMODULEPATH = $original_PSMODULEPATH
|
||||
$env:PSModulePath = $original_PSModulePath
|
||||
$env:XDG_CONFIG_HOME = $original_XDG_CONFIG_HOME
|
||||
$env:XDG_CACHE_HOME = $original_XDG_CACHE_HOME
|
||||
$env:XDG_DATA_HOME = $original_XDG_DATA_HOME
|
||||
@@ -91,11 +91,11 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
||||
& $powershell -noprofile `$PROFILE | Should Be $expected
|
||||
}
|
||||
|
||||
It @ItArgs "PSMODULEPATH should respect XDG_DATA_HOME" {
|
||||
$env:PSMODULEPATH = ""
|
||||
It @ItArgs "PSModulePath should respect XDG_DATA_HOME" {
|
||||
$env:PSModulePath = ""
|
||||
$env:XDG_DATA_HOME = $TestDrive
|
||||
$expected = [IO.Path]::Combine($TestDrive, "powershell", "Modules")
|
||||
$actual = & $powershell -noprofile `$env:PSMODULEPATH
|
||||
$actual = & $powershell -noprofile `$env:PSModulePath
|
||||
$actual | Should Match $expected
|
||||
}
|
||||
|
||||
|
||||
@@ -24,12 +24,12 @@ Describe 'use of a module from two runspaces' -Tags "CI" {
|
||||
}
|
||||
New-ModuleManifest @manifestParams
|
||||
|
||||
if ($env:PSMODULEPATH -notlike "*$TestModulePath*") {
|
||||
$env:PSMODULEPATH += "$([System.IO.Path]::PathSeparator)$TestModulePath"
|
||||
if ($env:PSModulePath -notlike "*$TestModulePath*") {
|
||||
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$TestModulePath"
|
||||
}
|
||||
}
|
||||
|
||||
$originalPSMODULEPATH = $env:PSMODULEPATH
|
||||
$originalPSModulePath = $env:PSModulePath
|
||||
try {
|
||||
|
||||
New-TestModule -Name 'Random' -Content @'
|
||||
@@ -67,7 +67,7 @@ Import-Module Random
|
||||
}
|
||||
|
||||
} finally {
|
||||
$env:PSMODULEPATH = $originalPSMODULEPATH
|
||||
$env:PSModulePath = $originalPSModulePath
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,9 +76,9 @@ Describe 'Module reloading with Class definition' -Tags "CI" {
|
||||
|
||||
BeforeAll {
|
||||
Set-Content -Path TestDrive:\TestModule.psm1 -Value @'
|
||||
$passedArgs = $args
|
||||
class Root { $passedIn = $passedArgs }
|
||||
function Get-PassedArgsRoot { [Root]::new().passedIn }
|
||||
$passedArgs = $args
|
||||
class Root { $passedIn = $passedArgs }
|
||||
function Get-PassedArgsRoot { [Root]::new().passedIn }
|
||||
function Get-PassedArgsNoRoot { $passedArgs }
|
||||
'@
|
||||
$Arg_Hello = 'Hello'
|
||||
|
||||
@@ -30,12 +30,12 @@ Describe 'NestedModules' -Tags "CI" {
|
||||
New-ModuleManifest @manifestParams
|
||||
|
||||
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\)[0].FullName)
|
||||
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
||||
$env:PSMODULEPATH += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||
if (-not ($env:PSModulePath -like "*$resolvedTestDrivePath*")) {
|
||||
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||
}
|
||||
}
|
||||
|
||||
$originalPSMODULEPATH = $env:PSMODULEPATH
|
||||
$originalPSModulePath = $env:PSModulePath
|
||||
|
||||
try {
|
||||
|
||||
@@ -120,7 +120,7 @@ using module WithRoot
|
||||
}
|
||||
|
||||
} finally {
|
||||
$env:PSMODULEPATH = $originalPSMODULEPATH
|
||||
$env:PSModulePath = $originalPSModulePath
|
||||
Get-Module @('ABC', 'NoRoot', 'WithRoot') | Remove-Module
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Describe 'using module' -Tags "CI" {
|
||||
BeforeAll {
|
||||
$originalPSMODULEPATH = $env:PSMODULEPATH
|
||||
$originalPSModulePath = $env:PSModulePath
|
||||
|
||||
Import-Module $PSScriptRoot\..\LanguageTestSupport.psm1
|
||||
|
||||
@@ -23,15 +23,15 @@ Describe 'using module' -Tags "CI" {
|
||||
}
|
||||
|
||||
$resolvedTestDrivePath = Split-Path ((get-childitem "${TestDrive}\$ModulePathPrefix")[0].FullName)
|
||||
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
||||
$env:PSMODULEPATH += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||
if (-not ($env:PSModulePath -like "*$resolvedTestDrivePath*")) {
|
||||
$env:PSModulePath += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
$env:PSMODULEPATH = $originalPSMODULEPATH
|
||||
$env:PSModulePath = $originalPSModulePath
|
||||
}
|
||||
|
||||
It 'Import-Module has ImplementedAssembly, when classes are present in the module' {
|
||||
@@ -349,7 +349,7 @@ using module Foo
|
||||
|
||||
# 'using module' behavior must be aligned with Import-Module.
|
||||
# Import-Module does the following:
|
||||
# 1) find the first directory from $env:PSMODULEPATH that contains the module
|
||||
# 1) find the first directory from $env:PSModulePath that contains the module
|
||||
# 2) Import highest available version of the module
|
||||
# In out case TestDrive:\Module is before TestDrive:\Modules2 and so 2.3.0 is the right version
|
||||
It "uses the last module, if multiple versions are present" {
|
||||
@@ -436,12 +436,12 @@ function foo()
|
||||
}
|
||||
|
||||
|
||||
# here we are back to normal $env:PSMODULEPATH, but all modules are there
|
||||
# here we are back to normal $env:PSModulePath, but all modules are there
|
||||
Context "Module by path" {
|
||||
BeforeAll {
|
||||
# this is a setup for Context "Module by path"
|
||||
New-TestModule -Name FooForPaths -Content 'class Foo { [string] GetModuleName() { return "FooForPaths" } }'
|
||||
$env:PSMODULEPATH = $originalPSMODULEPATH
|
||||
$env:PSModulePath = $originalPSModulePath
|
||||
|
||||
new-item -type directory -Force TestDrive:\FooRelativeConsumer
|
||||
Set-Content -Path "${TestDrive}\FooRelativeConsumer\FooRelativeConsumer.ps1" -Value @'
|
||||
@@ -457,8 +457,8 @@ class Bar : Foo {}
|
||||
'@
|
||||
}
|
||||
|
||||
It 'use non-modified PSMODULEPATH' {
|
||||
$env:PSMODULEPATH | Should Be $originalPSMODULEPATH
|
||||
It 'use non-modified PSModulePath' {
|
||||
$env:PSModulePath | Should Be $originalPSModulePath
|
||||
}
|
||||
|
||||
It "can be accessed by relative path" {
|
||||
|
||||
@@ -507,7 +507,7 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
||||
# <Summary>Unit tests for line breakpoints on modules...</Summary>
|
||||
# </Test>
|
||||
#
|
||||
$oldModulePath = $env:PSMODULEPATH
|
||||
$oldModulePath = $env:PSModulePath
|
||||
try
|
||||
{
|
||||
#
|
||||
@@ -560,7 +560,7 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
||||
#
|
||||
# Load the module
|
||||
#
|
||||
$ENV:PSMODULEPATH = $moduleRoot
|
||||
$ENV:PSModulePath = $moduleRoot
|
||||
|
||||
import-module $moduleName
|
||||
|
||||
@@ -594,7 +594,7 @@ Describe "Unit tests for line breakpoints on modules" -Tags "CI" {
|
||||
}
|
||||
finally
|
||||
{
|
||||
$env:PSMODULEPATH = $oldModulePath
|
||||
$env:PSModulePath = $oldModulePath
|
||||
if ($breakpoint1 -ne $null) { Remove-PSBreakpoint $breakpoint1 }
|
||||
if ($breakpoint2 -ne $null) { Remove-PSBreakpoint $breakpoint2 }
|
||||
if ($breakpoint3 -ne $null) { Remove-PSBreakpoint $breakpoint3 }
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
|
||||
AfterAll {
|
||||
$global:ProgressPreference = $_progressPreference
|
||||
$env:PSMODULEPATH = $_modulePath
|
||||
$env:PSModulePath = $_modulePath
|
||||
}
|
||||
BeforeAll {
|
||||
# remove the archive module forcefully, to be sure we get the correct version
|
||||
@@ -19,9 +19,9 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
# Write-Progress not supported yet on Core
|
||||
$_progressPreference = $ProgressPreference
|
||||
# we need to be sure that we get the correct archive module
|
||||
$_modulePath = $env:PSMODULEPATH
|
||||
$_modulePath = $env:PSModulePath
|
||||
$powershellexe = (get-process -pid $PID).MainModule.FileName
|
||||
$env:PSMODULEPATH = join-path ([io.path]::GetDirectoryName($powershellexe)) Modules
|
||||
$env:PSModulePath = join-path ([io.path]::GetDirectoryName($powershellexe)) Modules
|
||||
if ( $IsCoreCLR ) { $global:ProgressPreference = "SilentlyContinue" }
|
||||
|
||||
Setup -d SourceDir
|
||||
|
||||
@@ -163,8 +163,8 @@ Describe "CmsMessage cmdlets thorough tests" -Tags "Feature" {
|
||||
$fullPowerShell = Join-Path "$env:SystemRoot" "System32\WindowsPowerShell\v1.0\powershell.exe"
|
||||
|
||||
try {
|
||||
$modulePathCopy = $env:PSMODULEPATH
|
||||
$env:PSMODULEPATH = $null
|
||||
$modulePathCopy = $env:PSModulePath
|
||||
$env:PSModulePath = $null
|
||||
|
||||
$command = @"
|
||||
Import-PfxCertificate $certLocation -CertStoreLocation cert:\CurrentUser\My | % PSPath
|
||||
@@ -176,7 +176,7 @@ Import-Certificate $badCertLocation -CertStoreLocation Cert:\CurrentUser\My | %
|
||||
$importedCert = Get-ChildItem $certPaths[0]
|
||||
$testBadCert = Get-ChildItem $certPaths[1]
|
||||
} finally {
|
||||
$env:PSMODULEPATH = $modulePathCopy
|
||||
$env:PSModulePath = $modulePathCopy
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
Describe "DSC MOF Compilation" -tags "CI" {
|
||||
|
||||
AfterAll {
|
||||
$env:PSMODULEPATH = $_modulePath
|
||||
$env:PSModulePath = $_modulePath
|
||||
}
|
||||
BeforeAll {
|
||||
$env:DSC_HOME = Join-Path -Path (Join-Path -Path $PSScriptRoot -ChildPath assets) -ChildPath dsc
|
||||
$_modulePath = $env:PSMODULEPATH
|
||||
$_modulePath = $env:PSModulePath
|
||||
$powershellexe = (get-process -pid $PID).MainModule.FileName
|
||||
$env:PSMODULEPATH = join-path ([io.path]::GetDirectoryName($powershellexe)) Modules
|
||||
$env:PSModulePath = join-path ([io.path]::GetDirectoryName($powershellexe)) Modules
|
||||
}
|
||||
|
||||
It "Should be able to compile a MOF from a basic configuration" -Skip:($IsOSX -or $IsWindows) {
|
||||
|
||||
@@ -27,19 +27,19 @@
|
||||
}
|
||||
|
||||
It "Command lookup with duplicate paths" {
|
||||
$previousPath = $env:PSMODULEPATH
|
||||
$previousPath = $env:PSModulePath
|
||||
|
||||
try
|
||||
{
|
||||
New-Item -Path "$TestDrive\TestFunctionA" -ItemType Directory
|
||||
New-Item -Path "$TestDrive\\TestFunctionA\TestFunctionA.psm1" -Value "function TestFunctionA {}" | Out-Null
|
||||
|
||||
$env:PSMODULEPATH = "$TestDrive" + [System.IO.Path]::PathSeparator + "$TestDrive"
|
||||
$env:PSModulePath = "$TestDrive" + [System.IO.Path]::PathSeparator + "$TestDrive"
|
||||
(Get-command 'TestFunctionA').count | Should Be 1
|
||||
}
|
||||
finally
|
||||
{
|
||||
$env:PSMODULEPATH = $previousPath
|
||||
$env:PSModulePath = $previousPath
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,18 +32,18 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||
}
|
||||
|
||||
BeforeEach {
|
||||
$originalModulePath = $env:PSMODULEPATH
|
||||
$originalModulePath = $env:PSModulePath
|
||||
}
|
||||
|
||||
AfterEach {
|
||||
$env:PSMODULEPATH = $originalModulePath
|
||||
$env:PSModulePath = $originalModulePath
|
||||
}
|
||||
|
||||
|
||||
It "validate sxs module path" {
|
||||
|
||||
$env:PSMODULEPATH = ""
|
||||
$defaultModulePath = & $powershell -nopro -c '$env:PSMODULEPATH'
|
||||
$env:PSModulePath = ""
|
||||
$defaultModulePath = & $powershell -nopro -c '$env:PSModulePath'
|
||||
|
||||
$paths = $defaultModulePath -split [System.IO.Path]::PathSeparator
|
||||
|
||||
@@ -64,8 +64,8 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||
try {
|
||||
|
||||
## PSHome module path derived from another powershell core instance should be ignored
|
||||
$env:PSMODULEPATH = $fakePSHomeModuleDir
|
||||
$newModulePath = & $powershell -nopro -c '$env:PSMODULEPATH'
|
||||
$env:PSModulePath = $fakePSHomeModuleDir
|
||||
$newModulePath = & $powershell -nopro -c '$env:PSModulePath'
|
||||
$paths = $newModulePath -split [System.IO.Path]::PathSeparator
|
||||
|
||||
$paths.Count | Should Be 3
|
||||
@@ -85,8 +85,8 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
|
||||
|
||||
## non-pshome module path derived from another powershell core instance should be preserved
|
||||
$customeModules = Join-Path -Path $TestDrive -ChildPath 'CustomModules'
|
||||
$env:PSMODULEPATH = $fakePSHomeModuleDir, $customeModules -join ([System.IO.Path]::PathSeparator)
|
||||
$newModulePath = & $powershell -nopro -c '$env:PSMODULEPATH'
|
||||
$env:PSModulePath = $fakePSHomeModuleDir, $customeModules -join ([System.IO.Path]::PathSeparator)
|
||||
$newModulePath = & $powershell -nopro -c '$env:PSModulePath'
|
||||
$paths = $newModulePath -split [System.IO.Path]::PathSeparator
|
||||
|
||||
$paths.Count | Should Be 5
|
||||
|
||||
@@ -481,12 +481,12 @@ function Invoke-OpenCover
|
||||
try
|
||||
{
|
||||
# check to be sure that the module path is present
|
||||
# this isn't done earlier because there's no need to change env:psmodulepath unless we're going to really run tests
|
||||
$saveModPath = $env:psmodulepath
|
||||
$env:psmodulepath = "${PowerShellExeDirectory}\Modules"
|
||||
if ( ! (test-path $env:psmodulepath) )
|
||||
# this isn't done earlier because there's no need to change env:PSModulePath unless we're going to really run tests
|
||||
$saveModPath = $env:PSModulePath
|
||||
$env:PSModulePath = "${PowerShellExeDirectory}\Modules"
|
||||
if ( ! (test-path $env:PSModulePath) )
|
||||
{
|
||||
throw "${env:psmodulepath} does not exist"
|
||||
throw "${env:PSModulePath} does not exist"
|
||||
}
|
||||
|
||||
# invoke OpenCover elevated
|
||||
|
||||
Reference in New Issue
Block a user