|
1 | 1 | #requires -Module ModuleBuilder
|
2 | 2 |
|
3 |
| -Describe "Build-Module With Source1" { |
4 |
| - Context "When we call Build-Module" { |
5 |
| - $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -Passthru |
6 |
| - $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
| 3 | +Describe "When we call Build-Module" -Tag Integration { |
| 4 | + $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -Passthru |
| 5 | + $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
7 | 6 |
|
8 |
| - It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" { |
9 |
| - $Module | Should -Not -FileContentMatch '^Source$' |
10 |
| - } |
| 7 | + It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" { |
| 8 | + $Module | Should -Not -FileContentMatch '^Source$' |
| 9 | + } |
11 | 10 |
|
12 |
| - $Metadata = Import-Metadata $Output.Path |
| 11 | + $Metadata = Import-Metadata $Output.Path |
13 | 12 |
|
14 |
| - It "Should update FunctionsToExport in the manifest" { |
15 |
| - $Metadata.FunctionsToExport | Should -Be @("Get-Source", "Set-Source") |
16 |
| - } |
| 13 | + It "Should update FunctionsToExport in the manifest" { |
| 14 | + $Metadata.FunctionsToExport | Should -Be @("Get-Source", "Set-Source") |
| 15 | + } |
17 | 16 |
|
18 |
| - It "Should update AliasesToExport in the manifest" { |
19 |
| - $Metadata.AliasesToExport -match "GS" | Should -Not -BeNullOrEmpty |
20 |
| - } |
| 17 | + It "Should update AliasesToExport in the manifest" { |
| 18 | + $Metadata.AliasesToExport -match "GS" | Should -Not -BeNullOrEmpty |
| 19 | + } |
21 | 20 |
|
22 |
| - It "Should de-dupe and move using statements to the top of the file" { |
23 |
| - Select-String -Pattern "^using" -Path $Module | ForEach-Object LineNumber | Should -Be 1 |
24 |
| - } |
| 21 | + It "Should de-dupe and move using statements to the top of the file" { |
| 22 | + Select-String -Pattern "^using" -Path $Module | ForEach-Object LineNumber | Should -Be 1 |
| 23 | + } |
25 | 24 |
|
26 |
| - It "Will comment out the original using statements in their original positions" { |
27 |
| - (Select-String -Pattern "^#\s*using" -Path $Module).Count | Should -Be 3 |
28 |
| - } |
| 25 | + It "Will comment out the original using statements in their original positions" { |
| 26 | + (Select-String -Pattern "^#\s*using" -Path $Module).Count | Should -Be 3 |
29 | 27 | }
|
| 28 | +} |
30 | 29 |
|
31 |
| - Context "Regression test for #55: I can pass SourceDirectories" { |
32 |
| - $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -SourceDirectories "Private" -Passthru |
33 |
| - $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
| 30 | +Describe "Regression test for #55: I can pass SourceDirectories" -Tag Integration, Regression { |
| 31 | + $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -SourceDirectories "Private" -Passthru |
| 32 | + $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
34 | 33 |
|
35 |
| - It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" { |
36 |
| - $Module | Should -Not -FileContentMatch '^Source$' |
37 |
| - } |
| 34 | + It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" { |
| 35 | + $Module | Should -Not -FileContentMatch '^Source$' |
| 36 | + } |
38 | 37 |
|
39 |
| - $Metadata = Import-Metadata $Output.Path |
| 38 | + $Metadata = Import-Metadata $Output.Path |
40 | 39 |
|
41 |
| - It "Should not have any FunctionsToExport if SourceDirectories don't match the PublicFilter" { |
42 |
| - $Metadata.FunctionsToExport | Should -Be @() |
43 |
| - } |
| 40 | + It "Should not have any FunctionsToExport if SourceDirectories don't match the PublicFilter" { |
| 41 | + $Metadata.FunctionsToExport | Should -Be @() |
| 42 | + } |
44 | 43 |
|
45 |
| - It "Should de-dupe and move using statements to the top of the file" { |
46 |
| - Select-String -Pattern "^using" -Path $Module | ForEach-Object LineNumber | Should -Be 1 |
47 |
| - } |
| 44 | + It "Should de-dupe and move using statements to the top of the file" { |
| 45 | + Select-String -Pattern "^using" -Path $Module | ForEach-Object LineNumber | Should -Be 1 |
| 46 | + } |
48 | 47 |
|
49 |
| - It "Will comment out the original using statement in the original positions" { |
50 |
| - (Select-String -Pattern "^#\s*using" -Path $Module).Count | Should -Be 2 |
51 |
| - } |
| 48 | + It "Will comment out the original using statement in the original positions" { |
| 49 | + (Select-String -Pattern "^#\s*using" -Path $Module).Count | Should -Be 2 |
52 | 50 | }
|
| 51 | +} |
53 | 52 |
|
54 |
| - Context "Regression test for #55: I can pass SourceDirectories and PublicFilter" { |
55 |
| - $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -SourceDirectories "Private" -PublicFilter "P*\*" -Passthru |
56 |
| - $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
| 53 | +Describe "Regression test for #55: I can pass SourceDirectories and PublicFilter" -Tag Integration, Regression { |
| 54 | + $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -SourceDirectories "Private" -PublicFilter "P*\*" -Passthru |
| 55 | + $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
57 | 56 |
|
58 |
| - It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" { |
59 |
| - $Module | Should -Not -FileContentMatch '^Source$' |
60 |
| - } |
| 57 | + It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" { |
| 58 | + $Module | Should -Not -FileContentMatch '^Source$' |
| 59 | + } |
61 | 60 |
|
62 |
| - $Metadata = Import-Metadata $Output.Path |
| 61 | + $Metadata = Import-Metadata $Output.Path |
63 | 62 |
|
64 |
| - It "Should not have any FunctionsToExport if SourceDirectories don't match the PublicFilter" { |
65 |
| - $Metadata.FunctionsToExport | Should -Be @("GetFinale", "GetPreview") |
66 |
| - } |
| 63 | + It "Should not have any FunctionsToExport if SourceDirectories don't match the PublicFilter" { |
| 64 | + $Metadata.FunctionsToExport | Should -Be @("GetFinale", "GetPreview") |
| 65 | + } |
67 | 66 |
|
68 |
| - It "Should update AliasesToExport in the manifest" { |
69 |
| - $Metadata.AliasesToExport | Should -Be @("GF", "GP") |
70 |
| - } |
| 67 | + It "Should update AliasesToExport in the manifest" { |
| 68 | + $Metadata.AliasesToExport | Should -Be @("GF", "GP") |
| 69 | + } |
71 | 70 |
|
72 |
| - It "Should de-dupe and move using statements to the top of the file" { |
73 |
| - Select-String -Pattern "^using" -Path $Module | ForEach-Object LineNumber | Should -Be 1 |
74 |
| - } |
| 71 | + It "Should de-dupe and move using statements to the top of the file" { |
| 72 | + Select-String -Pattern "^using" -Path $Module | ForEach-Object LineNumber | Should -Be 1 |
| 73 | + } |
75 | 74 |
|
76 |
| - It "Will comment out the original using statement in the original positions" { |
77 |
| - (Select-String -Pattern "^#\s*using" -Path $Module).Count | Should -Be 2 |
78 |
| - } |
| 75 | + It "Will comment out the original using statement in the original positions" { |
| 76 | + (Select-String -Pattern "^#\s*using" -Path $Module).Count | Should -Be 2 |
79 | 77 | }
|
| 78 | +} |
80 | 79 |
|
81 |
| - Context "Regression test for #84: Multiple Aliases per command will Export" { |
82 |
| - $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -Passthru |
| 80 | +Describe "Regression test for #84: Multiple Aliases per command will Export" -Tag Integration, Regression { |
| 81 | + $Output = Build-Module $PSScriptRoot\Source1\build.psd1 -Passthru |
83 | 82 |
|
84 |
| - $Metadata = Import-Metadata $Output.Path |
| 83 | + $Metadata = Import-Metadata $Output.Path |
85 | 84 |
|
86 |
| - It "Should update AliasesToExport in the manifest" { |
87 |
| - $Metadata.AliasesToExport | Should -Be @("GS","GSou", "SS", "SSou") |
88 |
| - } |
| 85 | + It "Should update AliasesToExport in the manifest" { |
| 86 | + $Metadata.AliasesToExport | Should -Be @("GS","GSou", "SS", "SSou") |
89 | 87 | }
|
| 88 | +} |
90 | 89 |
|
91 |
| - Context "Supports building without a build.psd1" { |
92 |
| - Copy-Item $PSScriptRoot\Source1 $PSScriptRoot\Copy1 -Recurse |
93 |
| - Remove-Item $PSScriptRoot\Copy1\build.psd1 |
94 |
| - Rename-Item $PSScriptRoot\Copy1\Source1.psd1 Copy1.psd1 |
95 |
| - |
96 |
| - $Build = @{ } |
| 90 | +Describe "Supports building without a build.psd1" -Tag Integration { |
| 91 | + Copy-Item $PSScriptRoot\Source1 $PSScriptRoot\Copy1 -Recurse |
| 92 | + Remove-Item $PSScriptRoot\Copy1\build.psd1 |
| 93 | + Rename-Item $PSScriptRoot\Copy1\Source1.psd1 Copy1.psd1 |
97 | 94 |
|
98 |
| - It "No longer fails if there's no build.psd1" { |
99 |
| - $BuildParameters = @{ |
100 |
| - SourcePath = "$PSScriptRoot\Copy1\Copy1.psd1" |
101 |
| - OutputDirectory = "..\Result1" |
102 |
| - VersionedOutputDirectory = $true |
103 |
| - } |
| 95 | + $Build = @{ } |
104 | 96 |
|
105 |
| - $Build.Output = Build-Module @BuildParameters -Passthru |
| 97 | + It "No longer fails if there's no build.psd1" { |
| 98 | + $BuildParameters = @{ |
| 99 | + SourcePath = "$PSScriptRoot\Copy1\Copy1.psd1" |
| 100 | + OutputDirectory = "..\Result1" |
| 101 | + VersionedOutputDirectory = $true |
106 | 102 | }
|
107 | 103 |
|
108 |
| - Remove-Item -Recurse $PSScriptRoot\Copy1 |
| 104 | + $Build.Output = Build-Module @BuildParameters -Passthru |
| 105 | + } |
109 | 106 |
|
| 107 | + Remove-Item -Recurse $PSScriptRoot\Copy1 |
110 | 108 |
|
111 |
| - It "Creates the same module as with a build.psd1" { |
112 |
| - $Build.Metadata = Import-Metadata $Build.Output.Path |
113 |
| - } |
114 | 109 |
|
115 |
| - It "Should update AliasesToExport in the manifest" { |
116 |
| - $Build.Metadata.AliasesToExport | Should -Be @("GS", "GSou", "SS", "SSou") |
117 |
| - } |
| 110 | + It "Creates the same module as with a build.psd1" { |
| 111 | + $Build.Metadata = Import-Metadata $Build.Output.Path |
| 112 | + } |
118 | 113 |
|
119 |
| - It "Should update FunctionsToExport in the manifest" { |
120 |
| - $Build.Metadata.FunctionsToExport | Should -Be @("Get-Source", "Set-Source") |
121 |
| - } |
| 114 | + It "Should update AliasesToExport in the manifest" { |
| 115 | + $Build.Metadata.AliasesToExport | Should -Be @("GS", "GSou", "SS", "SSou") |
| 116 | + } |
122 | 117 |
|
| 118 | + It "Should update FunctionsToExport in the manifest" { |
| 119 | + $Build.Metadata.FunctionsToExport | Should -Be @("Get-Source", "Set-Source") |
| 120 | + } |
| 121 | +} |
| 122 | + |
| 123 | +Describe "Regression test for #88 not copying prefix files" -Tag Integration, Regression { |
| 124 | + $Output = Build-Module $PSScriptRoot\build.psd1 -Passthru |
| 125 | + |
| 126 | + $Metadata = Import-Metadata $Output.Path |
| 127 | + |
| 128 | + It "Should update AliasesToExport in the manifest" { |
| 129 | + $Module = [IO.Path]::ChangeExtension($Output.Path, "psm1") |
| 130 | + $ModuleInfo = Get-Content $Module |
| 131 | + $ModuleInfo[0] | Should -be "using module Configuration" |
123 | 132 | }
|
124 | 133 | }
|
0 commit comments