Skip to content

Commit e725a03

Browse files
Andrewadityapatwardhan
authored andcommitted
Updating ModulePath.Tests for fxdependent package (#7772)
1 parent 285e471 commit e725a03

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

test/powershell/engine/Module/ModulePath.Tests.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
2323
}
2424
$expectedSystemPath = Join-Path -Path $PSHOME -ChildPath 'Modules'
2525

26+
# Skip these tests in cases when there is no 'pwsh' executable (e.g. when framework dependent PS package is used)
27+
$skipNoPwsh = -not (Test-Path $powershell)
28+
2629
if ($IsWindows)
2730
{
2831
$expectedWindowsPowerShellPSHomePath = Join-Path $env:windir "System32" "WindowsPowerShell" "v1.0" "Modules"
@@ -46,7 +49,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
4649
$env:PSModulePath = $originalModulePath
4750
}
4851

49-
It "validate sxs module path" {
52+
It "validate sxs module path" -Skip:$skipNoPwsh {
5053

5154
$env:PSModulePath = ""
5255
$defaultModulePath = & $powershell -nopro -c '$env:PSModulePath'
@@ -71,7 +74,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
7174
}
7275
}
7376

74-
It "ignore pshome module path derived from a different powershell core instance" -Skip:(!$IsCoreCLR) {
77+
It "ignore pshome module path derived from a different powershell core instance" -Skip:(!$IsCoreCLR -or $skipNoPwsh) {
7578

7679
## Create 'powershell' and 'pwsh.deps.json' in the fake PSHome folder,
7780
## so that the module path calculation logic would believe it's real.
@@ -110,7 +113,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
110113
}
111114
}
112115

113-
It "keep non-pshome module path derived from powershell core instance parent" -Skip:(!$IsCoreCLR) {
116+
It "keep non-pshome module path derived from powershell core instance parent" -Skip:(!$IsCoreCLR -or $skipNoPwsh) {
114117

115118
## non-pshome module path derived from another powershell core instance should be preserved
116119
$customeModules = Join-Path -Path $TestDrive -ChildPath 'CustomModules'
@@ -130,7 +133,7 @@ Describe "SxS Module Path Basic Tests" -tags "CI" {
130133
$paths -contains $customeModules | Should -BeTrue
131134
}
132135

133-
It 'Ensures $PSHOME\Modules is inserted correctly when launched from a different version of PowerShell' -Skip:(!($IsCoreCLR -and $IsWindows)) {
136+
It 'Ensures $PSHOME\Modules is inserted correctly when launched from a different version of PowerShell' -Skip:(!($IsCoreCLR -and $IsWindows) -or $skipNoPwsh) {
134137
# When launched from a different version of PowerShell, PSModulePath contains the other version's PSHOME\Modules path
135138
# and the Windows PowerShell modoule path. THe other version's module path should be removed and this version's
136139
# PSHOME\Modules path should be inserted before Windows PowerShell module path.

0 commit comments

Comments
 (0)