Skip to content

Commit 8623c90

Browse files
committed
Update tests
1 parent 4aa3062 commit 8623c90

8 files changed

Lines changed: 176 additions & 196 deletions

File tree

Source/Private/GetBuildInfo.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function GetBuildInfo {
8383
}
8484

8585
if ((-not $BuildInfo.SourcePath) -and $ParameterValues["SourcePath"] -notmatch '\.psd1') {
86-
Write-Debug " Searching: SourcePath"
86+
Write-Debug " Searching: SourcePath ($BuildManifestParent\**\*.psd1)"
8787
# Find a module manifest (or maybe several)
8888
$ModuleInfo = Get-ChildItem $BuildManifestParent -Recurse -Filter *.psd1 -ErrorAction SilentlyContinue |
8989
ImportModuleManifest -ErrorAction SilentlyContinue

Source/Public/ConvertFrom-SourceLineNumber.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function ConvertFrom-SourceLineNumber {
2929
$Command = [IO.Path]::GetFileNameWithoutExtension($SourceFile)
3030
$Module = (Get-Command $Command -ErrorAction SilentlyContinue).Source
3131
if (!$Module) {
32-
Write-Warning "Please specify -Module for breakpoint ${SourceFile}: $SourceLineNumber"
32+
Write-Warning "Please specify -Module for ${SourceFile}: $SourceLineNumber"
3333
return
3434
}
3535
}

Tests/Integration/Source1.Tests.ps1

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,22 @@ Describe "Regression test for #55: I can pass SourceDirectories" -Tag Integratio
5252
}
5353

5454
Describe "Regression test for #55: I can pass SourceDirectories and PublicFilter" -Tag Integration, Regression {
55-
$Output = Build-Module $PSScriptRoot\Source1\build.psd1 -SourceDirectories "Private" -PublicFilter "P*\*" -Passthru
56-
$Module = [IO.Path]::ChangeExtension($Output.Path, "psm1")
55+
BeforeAll {
56+
$Output = Build-Module $PSScriptRoot\Source1\build.psd1 -SourceDirectories "Private" -PublicFilter "Pub*\*" -Passthru
57+
$Module = [IO.Path]::ChangeExtension($Output.Path, "psm1")
58+
$Metadata = Import-Metadata $Output.Path
59+
}
5760

5861
It "Should not put the module's DefaultCommandPrefix into the psm1 as code. Duh!" {
5962
$Module | Should -Not -FileContentMatch '^Source$'
6063
}
6164

62-
$Metadata = Import-Metadata $Output.Path
63-
6465
It "Should not have any FunctionsToExport if SourceDirectories don't match the PublicFilter" {
65-
$Metadata.FunctionsToExport | Should -Be @("Get-TestNotExportedAliases", "GetFinale", "GetPreview")
66+
$Metadata.FunctionsToExport | Should -BeNullOrEmpty
6667
}
6768

6869
It "Should update AliasesToExport in the manifest" {
69-
$Metadata.AliasesToExport | Should -Be @("GF", "GP")
70+
$Metadata.AliasesToExport | Should -Be @("Get-MyAlias")
7071
}
7172

7273
It "Should de-dupe and move using statements to the top of the file" {
@@ -111,6 +112,36 @@ Describe "Supports building without a build.psd1" -Tag Integration {
111112
$Build.Output = Build-Module @BuildParameters -Passthru
112113
}
113114

115+
It "Works even based on current path" {
116+
$BuildParameters = @{
117+
OutputDirectory = "TestDrive:\Result1"
118+
VersionedOutputDirectory = $true
119+
}
120+
Push-Location TestDrive:\Source1
121+
try {
122+
$Build.Output = Build-Module @BuildParameters -Passthru
123+
} finally {
124+
Pop-Location
125+
}
126+
}
127+
128+
# This test case for coverage of "If we found more than one module info"
129+
It "Ignores extra manifest files" {
130+
$BuildParameters = @{
131+
OutputDirectory = "TestDrive:\Result1"
132+
VersionedOutputDirectory = $true
133+
}
134+
Push-Location TestDrive:\Source1
135+
New-Item SubModule -ItemType Directory
136+
Copy-Item Source1.psd1 .\SubModule\SubModule.psd1
137+
138+
try {
139+
$Build.Output = Build-Module @BuildParameters -Passthru
140+
} finally {
141+
Pop-Location
142+
}
143+
}
144+
114145
It "Creates the same module as with a build.psd1" {
115146
$Build.Metadata = Import-Metadata $Build.Output.Path
116147
Get-Content $Build.Output.Path | Should -Be $ManifestContent
@@ -126,7 +157,6 @@ Describe "Supports building without a build.psd1" -Tag Integration {
126157
}
127158
}
128159

129-
130160
Describe "Defaults to VersionedOutputDirectory" -Tag Integration {
131161
Copy-Item $PSScriptRoot\Source1 TestDrive:\Source1 -Recurse
132162
# This is the old build, with a build.psd1
@@ -176,8 +206,6 @@ Describe "Defaults to VersionedOutputDirectory" -Tag Integration {
176206
}
177207
}
178208

179-
180-
181209
Describe "Supports building discovering the module without a build.psd1" -Tag Integration {
182210
Copy-Item $PSScriptRoot\Source1 TestDrive:\source -Recurse
183211

File renamed without changes.

Tests/Integration/Source1/Private/GetFinale.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ using module ModuleBuilder
22

33
function GetFinale {
44
[CmdletBinding()]
5-
[Alias("gf")]
5+
# [Alias("gf")]
66
param()
77
}

Tests/Integration/Source1/Private/GetPreview.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ using module ModuleBuilder
22

33
function GetPreview {
44
[CmdletBinding()]
5-
[Alias("gp")]
5+
# [Alias("gp")]
66
param()
77
}

0 commit comments

Comments
 (0)