2
2
. $PSScriptRoot \..\Convert-FolderSeparator.ps1
3
3
4
4
Describe " When we call Build-Module" - Tag Integration {
5
- $Output = Build-Module $PSScriptRoot \Source1\build.psd1 - Passthru
6
- $Module = [IO.Path ]::ChangeExtension($Output.Path , " psm1" )
5
+ BeforeAll {
6
+ $Output = Build-Module $PSScriptRoot \Source1\build.psd1 - Passthru
7
+ $Module = [IO.Path ]::ChangeExtension($Output.Path , " psm1" )
8
+ $Metadata = Import-Metadata $Output.Path
9
+ }
7
10
8
11
It " Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" {
9
12
$Module | Should -Not - FileContentMatch ' ^Source$'
10
13
}
11
14
12
- $Metadata = Import-Metadata $Output.Path
13
15
14
16
It " Should update FunctionsToExport in the manifest" {
15
17
$Metadata.FunctionsToExport | Should - Be @ (" Get-Source" , " Set-Source" )
@@ -29,14 +31,16 @@ Describe "When we call Build-Module" -Tag Integration {
29
31
}
30
32
31
33
Describe " Regression test for #55: I can pass SourceDirectories" - Tag Integration, Regression {
32
- $Output = Build-Module $PSScriptRoot \Source1\build.psd1 - SourceDirectories " Private" - Passthru
33
- $Module = [IO.Path ]::ChangeExtension($Output.Path , " psm1" )
34
+ BeforeAll {
35
+ $Output = Build-Module $PSScriptRoot \Source1\build.psd1 - SourceDirectories " Private" - Passthru
36
+ $Module = [IO.Path ]::ChangeExtension($Output.Path , " psm1" )
37
+ $Metadata = Import-Metadata $Output.Path
38
+ }
34
39
35
40
It " Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" {
36
41
$Module | Should -Not - FileContentMatch ' ^Source$'
37
42
}
38
43
39
- $Metadata = Import-Metadata $Output.Path
40
44
41
45
It " Should not have any FunctionsToExport if SourceDirectories don't match the PublicFilter" {
42
46
$Metadata.FunctionsToExport | Should - Be @ ()
@@ -80,27 +84,30 @@ Describe "Regression test for #55: I can pass SourceDirectories and PublicFilter
80
84
}
81
85
82
86
Describe " Regression test for #84: Multiple Aliases per command will Export" - Tag Integration, Regression {
83
- $Output = Build-Module $PSScriptRoot \Source1\build.psd1 - Passthru
84
-
85
- $Metadata = Import-Metadata $Output.Path
87
+ BeforeAll {
88
+ $Output = Build-Module $PSScriptRoot \Source1\build.psd1 - Passthru
89
+ $Metadata = Import-Metadata $Output.Path
90
+ }
86
91
87
92
It " Should update AliasesToExport in the manifest" {
88
93
$Metadata.AliasesToExport | Should - Be @ (" Get-MyAlias" , " GS" , " GSou" , " SS" , " SSou" )
89
94
}
90
95
}
91
96
92
97
Describe " Supports building without a build.psd1" - Tag Integration {
93
- Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
94
- # This is the old build, with a build.psd1
95
- $Output = Build-Module TestDrive:\Source1\build.psd1 - Passthru
96
- $ManifestContent = Get-Content $Output.Path
97
- $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
98
- Remove-Item (Split-Path $Output.Path ) - Recurse
98
+ BeforeAll {
99
+ Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
100
+ # This is the old build, with a build.psd1
101
+ $Output = Build-Module TestDrive:\Source1\build.psd1 - Passthru
102
+ $ManifestContent = Get-Content $Output.Path
103
+ $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
104
+ Remove-Item (Split-Path $Output.Path ) - Recurse
99
105
100
- # Then remove the build.psd1 and rebuild it
101
- Remove-Item TestDrive:\Source1\build.psd1
106
+ # Then remove the build.psd1 and rebuild it
107
+ Remove-Item TestDrive:\Source1\build.psd1
102
108
103
- $Build = @ { }
109
+ $Build = @ { }
110
+ }
104
111
105
112
It " No longer fails if there's no build.psd1" {
106
113
$BuildParameters = @ {
@@ -158,17 +165,19 @@ Describe "Supports building without a build.psd1" -Tag Integration {
158
165
}
159
166
160
167
Describe " Defaults to VersionedOutputDirectory" - Tag Integration {
161
- Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
162
- # This is the old build, with a build.psd1
163
- $Output = Build-Module TestDrive:\Source1\build.psd1 - Passthru
164
- $ManifestContent = Get-Content $Output.Path
165
- $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
166
- Remove-Item (Split-Path $Output.Path ) - Recurse
168
+ BeforeAll {
169
+ Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
170
+ # This is the old build, with a build.psd1
171
+ $Output = Build-Module TestDrive:\Source1\build.psd1 - Passthru
172
+ $ManifestContent = Get-Content $Output.Path
173
+ $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
174
+ Remove-Item (Split-Path $Output.Path ) - Recurse
167
175
168
- # Then remove the build.psd1 and rebuild it
169
- Remove-Item TestDrive:\Source1\build.psd1
176
+ # Then remove the build.psd1 and rebuild it
177
+ Remove-Item TestDrive:\Source1\build.psd1
170
178
171
- $Build = @ { }
179
+ $Build = @ { }
180
+ }
172
181
173
182
It " Builds into a folder with version by default" {
174
183
$BuildParameters = @ {
@@ -207,20 +216,22 @@ Describe "Defaults to VersionedOutputDirectory" -Tag Integration {
207
216
}
208
217
209
218
Describe " Supports building discovering the module without a build.psd1" - Tag Integration {
210
- Copy-Item $PSScriptRoot \Source1 TestDrive:\source - Recurse
219
+ BeforeAll {
220
+ Copy-Item $PSScriptRoot \Source1 TestDrive:\source - Recurse
211
221
212
- # This is the old build, with a build.psd1
213
- $Output = Build-Module TestDrive:\source\build.psd1 - Passthru
214
- $ManifestContent = Get-Content $Output.Path
215
- $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
216
- Remove-Item (Split-Path $Output.Path ) - Recurse
222
+ # This is the old build, with a build.psd1
223
+ $Output = Build-Module TestDrive:\source\build.psd1 - Passthru
224
+ $ManifestContent = Get-Content $Output.Path
225
+ $ModuleContent = Get-Content ([IO.Path ]::ChangeExtension($Output.Path , " .psm1" ))
226
+ Remove-Item (Split-Path $Output.Path ) - Recurse
217
227
218
- # Then remove the build.psd1 and rebuild it
219
- Remove-Item TestDrive:\source\build.psd1
228
+ # Then remove the build.psd1 and rebuild it
229
+ Remove-Item TestDrive:\source\build.psd1
220
230
221
- Push-Location - StackName ' IntegrationTest' - Path TestDrive:\
231
+ Push-Location - StackName ' IntegrationTest' - Path TestDrive:\
222
232
223
- $Build = @ { }
233
+ $Build = @ { }
234
+ }
224
235
225
236
It " No longer fails if there's no build.psd1" {
226
237
$Build.Output = Build-Module - Passthru
@@ -240,13 +251,16 @@ Describe "Supports building discovering the module without a build.psd1" -Tag In
240
251
$Build.Metadata.FunctionsToExport | Should - Be @ (" Get-Source" , " Set-Source" )
241
252
}
242
253
243
- Pop-Location - StackName ' IntegrationTest'
254
+ AfterAll {
255
+ Pop-Location - StackName ' IntegrationTest'
256
+ }
244
257
}
245
258
246
259
Describe " Regression test for #88 not copying prefix files" - Tag Integration, Regression {
247
- $Output = Build-Module $PSScriptRoot \build.psd1 - Passthru
248
-
249
- $Metadata = Import-Metadata $Output.Path
260
+ BeforeAll {
261
+ $Output = Build-Module $PSScriptRoot \build.psd1 - Passthru
262
+ $Metadata = Import-Metadata $Output.Path
263
+ }
250
264
251
265
It " Should update AliasesToExport in the manifest" {
252
266
$Module = [IO.Path ]::ChangeExtension($Output.Path , " psm1" )
@@ -256,20 +270,22 @@ Describe "Regression test for #88 not copying prefix files" -Tag Integration, Re
256
270
}
257
271
258
272
Describe " Regression test for #40.2 not copying suffix if prefix" - Tag Integration, Regression {
259
- Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
273
+ BeforeAll {
274
+ Copy-Item $PSScriptRoot \Source1 TestDrive:\Source1 - Recurse
260
275
261
- New-Item TestDrive:\Source1\_GlobalScope.ps1 - Value ' $Global:Module = "Testing"'
276
+ New-Item TestDrive:\Source1\_GlobalScope.ps1 - Value ' $Global:Module = "Testing"'
262
277
263
- $metadata = Import-Metadata TestDrive:\Source1\build.psd1
264
- $metadata += @ {
265
- Prefix = " ./_GlobalScope.ps1"
266
- Suffix = " ./_GlobalScope.ps1"
267
- }
268
- $metadata | Export-Metadata TestDrive:\Source1\build.psd1
278
+ $metadata = Import-Metadata TestDrive:\Source1\build.psd1
279
+ $metadata += @ {
280
+ Prefix = " ./_GlobalScope.ps1"
281
+ Suffix = " ./_GlobalScope.ps1"
282
+ }
283
+ $metadata | Export-Metadata TestDrive:\Source1\build.psd1
269
284
270
- $Output = Build-Module TestDrive:\Source1 - Passthru
285
+ $Output = Build-Module TestDrive:\Source1 - Passthru
271
286
272
- $Metadata = Import-Metadata $Output.Path
287
+ $Metadata = Import-Metadata $Output.Path
288
+ }
273
289
274
290
It " Should inject the content of the _GlobalScope file at the TOP and BOTTOM" {
275
291
$Module = [IO.Path ]::ChangeExtension($Output.Path , " psm1" )
@@ -288,10 +304,12 @@ Describe "Regression test for #40.2 not copying suffix if prefix" -Tag Integrati
288
304
# There's no such thing as a drive root on unix
289
305
if ($PSVersionTable.Platform -eq " Win32NT" ) {
290
306
Describe " Able to build from the drive root" {
291
- $null = New-ModuleManifest " TestDrive:/MyModule.psd1" - ModuleVersion " 1.0.0" - Author " Tester"
292
- $null = New-Item " TestDrive:/Public/Test.ps1" - Type File - Value ' MATCHING TEST CONTENT' - Force
307
+ BeforeAll {
308
+ $null = New-ModuleManifest " TestDrive:/MyModule.psd1" - ModuleVersion " 1.0.0" - Author " Tester"
309
+ $null = New-Item " TestDrive:/Public/Test.ps1" - Type File - Value ' MATCHING TEST CONTENT' - Force
293
310
294
- $Result = Build-Module - SourcePath ' TestDrive:/MyModule.psd1' - Version " 1.0.0" - OutputDirectory ' ./output' - Encoding UTF8 - SourceDirectories @ (' Public' ) - Target Build - Passthru
311
+ $Result = Build-Module - SourcePath ' TestDrive:/MyModule.psd1' - Version " 1.0.0" - OutputDirectory ' ./output' - Encoding UTF8 - SourceDirectories @ (' Public' ) - Target Build - Passthru
312
+ }
295
313
296
314
It " Builds the Module in the designated output folder" {
297
315
$Result.ModuleBase | Convert-FolderSeparator | Should - Be (Convert-FolderSeparator " TestDrive:/Output/MyModule/1.0.0" )
@@ -301,20 +319,21 @@ if ($PSVersionTable.Platform -eq "Win32NT") {
301
319
}
302
320
303
321
Describe " Copies additional items specified in CopyPaths" {
322
+ BeforeAll {
323
+ $null = New-Item " TestDrive:/build.psd1" - Type File - Force - Value " @{
324
+ SourcePath = 'TestDrive:/MyModule.psd1'
325
+ SourceDirectories = @('Public')
326
+ OutputDirectory = './output'
327
+ CopyPaths = './lib', './MyModule.format.ps1xml'
328
+ }"
329
+ $null = New-ModuleManifest " TestDrive:/MyModule.psd1" - ModuleVersion " 1.0.0" - Author " Tester"
330
+ $null = New-Item " TestDrive:/Public/Test.ps1" - Type File - Value ' MATCHING TEST CONTENT' - Force
331
+ $null = New-Item " TestDrive:/MyModule.format.ps1xml" - Type File - Value ' <Configuration />' - Force
332
+ $null = New-Item " TestDrive:/lib/imaginary1.dll" - Type File - Value ' 1' - Force
333
+ $null = New-Item " TestDrive:/lib/subdir/imaginary2.dll" - Type File - Value ' 2' - Force
304
334
305
- $null = New-Item " TestDrive:/build.psd1" - Type File - Force - Value " @{
306
- SourcePath = 'TestDrive:/MyModule.psd1'
307
- SourceDirectories = @('Public')
308
- OutputDirectory = './output'
309
- CopyPaths = './lib', './MyModule.format.ps1xml'
310
- }"
311
- $null = New-ModuleManifest " TestDrive:/MyModule.psd1" - ModuleVersion " 1.0.0" - Author " Tester"
312
- $null = New-Item " TestDrive:/Public/Test.ps1" - Type File - Value ' MATCHING TEST CONTENT' - Force
313
- $null = New-Item " TestDrive:/MyModule.format.ps1xml" - Type File - Value ' <Configuration />' - Force
314
- $null = New-Item " TestDrive:/lib/imaginary1.dll" - Type File - Value ' 1' - Force
315
- $null = New-Item " TestDrive:/lib/subdir/imaginary2.dll" - Type File - Value ' 2' - Force
316
-
317
- $Result = Build-Module - SourcePath ' TestDrive:/build.psd1' - OutputDirectory ' ./output' - Version ' 1.0.0' - Passthru - Target Build
335
+ $Result = Build-Module - SourcePath ' TestDrive:/build.psd1' - OutputDirectory ' ./output' - Version ' 1.0.0' - Passthru - Target Build
336
+ }
318
337
319
338
It " Copies single files that are in CopyPaths" {
320
339
(Convert-FolderSeparator $Result.ModuleBase ) | Should - Be (Convert-FolderSeparator " $TestDrive /output/MyModule/1.0.0" )
0 commit comments