From df07e2fad5d52e63a8d60deba838f33de10a753e Mon Sep 17 00:00:00 2001 From: Andrew Menagarishvili Date: Wed, 12 Sep 2018 13:35:28 -0700 Subject: [PATCH 1/2] Updating ModulePath.Tests for fxdependent package --- .../engine/Module/ModulePath.Tests.ps1 | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/powershell/engine/Module/ModulePath.Tests.ps1 b/test/powershell/engine/Module/ModulePath.Tests.ps1 index 11f628f66e9..ecae785884c 100644 --- a/test/powershell/engine/Module/ModulePath.Tests.ps1 +++ b/test/powershell/engine/Module/ModulePath.Tests.ps1 @@ -23,6 +23,16 @@ 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) + if ( -not (Test-Path $powershell)) + { + $skipNoPwsh = $true + } + else + { + $skipNoPwsh = $false + } + if ($IsWindows) { $expectedWindowsPowerShellPSHomePath = Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules" @@ -46,7 +56,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 +81,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 +120,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 +140,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. From bf2c7b68adbfbd86c5251acf67a0430086c20144 Mon Sep 17 00:00:00 2001 From: Andrew Menagarishvili Date: Wed, 12 Sep 2018 14:15:02 -0700 Subject: [PATCH 2/2] replaced if condition with shorter syntax --- test/powershell/engine/Module/ModulePath.Tests.ps1 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/test/powershell/engine/Module/ModulePath.Tests.ps1 b/test/powershell/engine/Module/ModulePath.Tests.ps1 index ecae785884c..d0fbd2247bf 100644 --- a/test/powershell/engine/Module/ModulePath.Tests.ps1 +++ b/test/powershell/engine/Module/ModulePath.Tests.ps1 @@ -24,15 +24,8 @@ 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) - if ( -not (Test-Path $powershell)) - { - $skipNoPwsh = $true - } - else - { - $skipNoPwsh = $false - } - + $skipNoPwsh = -not (Test-Path $powershell) + if ($IsWindows) { $expectedWindowsPowerShellPSHomePath = Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"