22# Licensed under the MIT License.
33Describe " Test-ModuleManifest tests" - tags " CI" {
44
5+ BeforeEach {
6+ $testModulePath = " testdrive:/module/test.psd1"
7+ New-Item - ItemType Directory - Path testdrive:/ module > $null
8+ }
9+
510 AfterEach {
611 Remove-Item - Recurse - Force - ErrorAction SilentlyContinue testdrive:/ module
712 }
813
914 It " module manifest containing paths with backslashes or forwardslashes are resolved correctly" {
1015
11- New-Item - ItemType Directory - Path testdrive:/ module
12- New-Item - ItemType Directory - Path testdrive:/ module/ foo
13- New-Item - ItemType Directory - Path testdrive:/ module/ bar
14- New-Item - ItemType File - Path testdrive:/ module/ foo/ bar.psm1
15- New-Item - ItemType File - Path testdrive:/ module/ bar/ foo.psm1
16+ New-Item - ItemType Directory - Path testdrive:/ module/ foo > $null
17+ New-Item - ItemType Directory - Path testdrive:/ module/ bar > $null
18+ New-Item - ItemType File - Path testdrive:/ module/ foo/ bar.psm1 > $null
19+ New-Item - ItemType File - Path testdrive:/ module/ bar/ foo.psm1 > $null
1620 $testModulePath = " testdrive:/module/test.psd1"
1721 $fileList = " foo\bar.psm1" , " bar/foo.psm1"
1822
@@ -38,10 +42,8 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
3842
3943 param ($parameter , $error )
4044
41- New-Item - ItemType Directory - Path testdrive:/ module
42- New-Item - ItemType Directory - Path testdrive:/ module/ foo
43- New-Item - ItemType File - Path testdrive:/ module/ foo/ bar.psm1
44- $testModulePath = " testdrive:/module/test.psd1"
45+ New-Item - ItemType Directory - Path testdrive:/ module/ foo > $null
46+ New-Item - ItemType File - Path testdrive:/ module/ foo/ bar.psm1 > $null
4547
4648 $args = @ {$parameter = " doesnotexist.psm1" }
4749 New-ModuleManifest - Path $testModulePath @args
@@ -57,10 +59,7 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
5759
5860 param ($rootModuleValue )
5961
60- New-Item - ItemType Directory - Path testdrive:/ module
61- $testModulePath = " testdrive:/module/test.psd1"
62-
63- New-Item - ItemType File - Path testdrive:/ module/ $rootModuleValue
62+ New-Item - ItemType File - Path testdrive:/ module/ $rootModuleValue > $null
6463 New-ModuleManifest - Path $testModulePath - RootModule $rootModuleValue
6564 $moduleManifest = Test-ModuleManifest - Path $testModulePath - ErrorAction Stop
6665 $moduleManifest | Should - BeOfType System.Management.Automation.PSModuleInfo
@@ -74,10 +73,7 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
7473
7574 param ($rootModuleValue , $error )
7675
77- New-Item - ItemType Directory - Path testdrive:/ module
78- $testModulePath = " testdrive:/module/test.psd1"
79-
80- New-Item - ItemType File - Path testdrive:/ module/ $rootModuleValue
76+ New-Item - ItemType File - Path testdrive:/ module/ $rootModuleValue > $null
8177 New-ModuleManifest - Path $testModulePath - RootModule $rootModuleValue
8278 { Test-ModuleManifest - Path $testModulePath - ErrorAction Stop } | Should - Throw - ErrorId " $error ,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
8379 }
@@ -89,9 +85,6 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
8985
9086 param ($rootModuleValue )
9187
92- New-Item - ItemType Directory - Path testdrive:/ module
93- $testModulePath = " testdrive:/module/test.psd1"
94-
9588 New-ModuleManifest - Path $testModulePath - RootModule $rootModuleValue
9689 $moduleManifest = Test-ModuleManifest - Path $testModulePath - ErrorAction Stop
9790 $moduleManifest | Should - BeOfType System.Management.Automation.PSModuleInfo
@@ -104,9 +97,7 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
10497
10598 param ($rootModuleValue , $error )
10699
107- $testModulePath = " testdrive:/module/test.psd1"
108- New-Item - ItemType Directory - Path testdrive:/ module
109- New-Item - ItemType File - Path testdrive:/ module/ $rootModuleValue
100+ New-Item - ItemType File - Path testdrive:/ module/ $rootModuleValue > $null
110101
111102 New-ModuleManifest - Path $testModulePath - RootModule $rootModuleValue
112103 { Test-ModuleManifest - Path $testModulePath - ErrorAction Stop } | Should - Throw - ErrorId " $error ,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
@@ -118,12 +109,23 @@ Describe "Test-ModuleManifest tests" -tags "CI" {
118109
119110 param ($rootModuleValue , $error )
120111
121- $testModulePath = " testdrive:/module/test.psd1"
122- New-Item - ItemType Directory - Path testdrive:/ module
123-
124112 New-ModuleManifest - Path $testModulePath - RootModule $rootModuleValue
125113 { Test-ModuleManifest - Path $testModulePath - ErrorAction Stop } | Should - Throw - ErrorId " $error ,Microsoft.PowerShell.Commands.TestModuleManifestCommand"
126114 }
115+
116+ It " module manifest containing nested module gets returned: <variation>" - TestCases (
117+ @ {variation = " no analysis as all exported with no wildcard" ; exportValue = " @()" },
118+ @ {variation = " analysis as exported with wildcard" ; exportValue = " *" }
119+ ) {
120+
121+ param ($exportValue )
122+
123+ New-Item - ItemType File - Path testdrive:/ module/ Foo.psm1 > $null
124+ New-ModuleManifest - Path $testModulePath - NestedModules " Foo.psm1" - FunctionsToExport $exportValue - CmdletsToExport $exportValue - VariablesToExport $exportValue - AliasesToExport $exportValue
125+ $module = Test-ModuleManifest - Path $testModulePath
126+ $module.NestedModules | Should - HaveCount 1
127+ $module.NestedModules.Name | Should - BeExactly " Foo"
128+ }
127129}
128130
129131Describe " Tests for circular references in required modules" - tags " CI" {
@@ -174,7 +176,7 @@ Describe "Tests for circular references in required modules" -tags "CI" {
174176 function TestImportModule ([bool ]$AddVersion , [bool ]$AddGuid , [bool ]$AddCircularReference )
175177 {
176178 $moduleRootPath = Join-Path $TestDrive ' TestModules'
177- New-Item $moduleRootPath - ItemType Directory - Force
179+ New-Item $moduleRootPath - ItemType Directory - Force > $null
178180 Push-Location $moduleRootPath
179181
180182 $moduleCount = 6 # this depth was enough to find a bug in cyclic reference detection product code; greater depth will slow tests down
0 commit comments