From e725a030d77593d2843deeddecc5fcf0af81998b Mon Sep 17 00:00:00 2001 From: Andrew Date: Mon, 17 Sep 2018 13:22:00 -0700 Subject: [PATCH] Updating ModulePath.Tests for fxdependent package (#7772) --- test/powershell/engine/Module/ModulePath.Tests.ps1 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/test/powershell/engine/Module/ModulePath.Tests.ps1 b/test/powershell/engine/Module/ModulePath.Tests.ps1 index 11f628f66e..d0fbd2247b 100644 --- a/test/powershell/engine/Module/ModulePath.Tests.ps1 +++ b/test/powershell/engine/Module/ModulePath.Tests.ps1 @@ -23,6 +23,9 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { } $expectedSystemPath = Join-Path -Path $PSHOME -ChildPath 'Modules' + # Skip these tests in cases when there is no 'pwsh' executable (e.g. when framework dependent PS package is used) + $skipNoPwsh = -not (Test-Path $powershell) + if ($IsWindows) { $expectedWindowsPowerShellPSHomePath = Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules" @@ -46,7 +49,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { $env:PSModulePath = $originalModulePath } - It "validate sxs module path" { + It "validate sxs module path" -Skip:$skipNoPwsh { $env:PSModulePath = "" $defaultModulePath = & $powershell -nopro -c '$env:PSModulePath' @@ -71,7 +74,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { } } - It "ignore pshome module path derived from a different powershell core instance" -Skip:(!$IsCoreCLR) { + It "ignore pshome module path derived from a different powershell core instance" -Skip:(!$IsCoreCLR -or $skipNoPwsh) { ## Create 'powershell' and 'pwsh.deps.json' in the fake PSHome folder, ## so that the module path calculation logic would believe it's real. @@ -110,7 +113,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { } } - It "keep non-pshome module path derived from powershell core instance parent" -Skip:(!$IsCoreCLR) { + It "keep non-pshome module path derived from powershell core instance parent" -Skip:(!$IsCoreCLR -or $skipNoPwsh) { ## non-pshome module path derived from another powershell core instance should be preserved $customeModules = Join-Path -Path $TestDrive -ChildPath 'CustomModules' @@ -130,7 +133,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" { $paths -contains $customeModules | Should -BeTrue } - It 'Ensures $PSHOME\Modules is inserted correctly when launched from a different version of PowerShell' -Skip:(!($IsCoreCLR -and $IsWindows)) { + It 'Ensures $PSHOME\Modules is inserted correctly when launched from a different version of PowerShell' -Skip:(!($IsCoreCLR -and $IsWindows) -or $skipNoPwsh) { # When launched from a different version of PowerShell, PSModulePath contains the other version's PSHOME\Modules path # and the Windows PowerShell modoule path. THe other version's module path should be removed and this version's # PSHOME\Modules path should be inserted before Windows PowerShell module path.