Skip to content

Commit c128593

Browse files
committed
Fix integration test and test.ps1
1 parent 12d5fd9 commit c128593

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

Tests/Integration/Source1.Tests.ps1

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,25 +88,21 @@ Describe "Regression test for #84: Multiple Aliases per command will Export" -Ta
8888
}
8989

9090
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
91+
Copy-Item $PSScriptRoot\Source1 TestDrive:\Source1 -Recurse
92+
Remove-Item TestDrive:\Source1\build.psd1
9493

9594
$Build = @{ }
9695

9796
It "No longer fails if there's no build.psd1" {
9897
$BuildParameters = @{
99-
SourcePath = "$PSScriptRoot\Copy1\Copy1.psd1"
100-
OutputDirectory = "..\Result1"
98+
SourcePath = "TestDrive:\Source1\Source1.psd1"
99+
OutputDirectory = "TestDrive:\Result1"
101100
VersionedOutputDirectory = $true
102101
}
103102

104103
$Build.Output = Build-Module @BuildParameters -Passthru
105104
}
106105

107-
Remove-Item -Recurse $PSScriptRoot\Copy1
108-
109-
110106
It "Creates the same module as with a build.psd1" {
111107
$Build.Metadata = Import-Metadata $Build.Output.Path
112108
}

test.ps1

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
using namespace Microsoft.PackageManagement.Provider.Utility
33
param(
44
[switch]$SkipCodeCoverage,
5-
[switch]$HideSuccess
5+
[switch]$HideSuccess,
66
[switch]$IncludeVSCodeMarker
77
)
88
Push-Location $PSScriptRoot
9-
$ModuleUnderTest = Split-Path $PSScriptRoot -Leaf
9+
$ModuleName = "ModuleBuilder"
1010

1111
# Disable default parameters during testing, just in case
1212
$PSDefaultParameterValues += @{}
@@ -15,10 +15,10 @@ $PSDefaultParameterValues["Disabled"] = $true
1515
# Find a built module as a version-numbered folder:
1616
$FullModulePath = Get-ChildItem [0-9]* -Directory | Sort-Object { $_.Name -as [SemanticVersion[]] } |
1717
Select-Object -Last 1 -Ov Version |
18-
Get-ChildItem -Filter "$($ModuleUnderTest).psd1"
18+
Get-ChildItem -Filter "$($ModuleName).psd1"
1919

20-
if(!$FullModulePath) {
21-
throw "Can't find $($ModuleUnderTest).psd1 in $($Version.FullName)"
20+
if (!$FullModulePath) {
21+
throw "Can't find $($ModuleName).psd1 in $($Version.FullName)"
2222
}
2323

2424
$Show = if ($HideSuccess) {
@@ -27,15 +27,15 @@ $Show = if ($HideSuccess) {
2727
"All"
2828
}
2929

30-
Remove-Module (Split-Path $ModuleUnderTest -Leaf) -ErrorAction Ignore -Force
30+
Remove-Module (Split-Path $ModuleName -Leaf) -ErrorAction Ignore -Force
3131
$ModuleUnderTest = Import-Module $FullModulePath -PassThru -Force -DisableNameChecking -Verbose:$false
3232
Write-Host "Invoke-Pester for Module $($ModuleUnderTest) version $($ModuleUnderTest.Version)"
3333

3434
if (-not $SkipCodeCoverage) {
3535
# Get code coverage for the psm1 file to a coverage.xml that we can mess with later
36-
Invoke-Pester (Join-Path $PSScriptRoot Tests) -CodeCoverage $ModuleUnderTest.Path -CodeCoverageOutputFile ./coverage.xml -Show $Show -PesterOption @{ IncludeVSCodeMarker = $IncludeVSCodeMarker }
36+
Invoke-Pester ./Tests -CodeCoverage $ModuleUnderTest.Path -CodeCoverageOutputFile ./coverage.xml -Show $Show -PesterOption @{ IncludeVSCodeMarker = $IncludeVSCodeMarker }
3737
} else {
38-
Invoke-Pester (Join-Path $PSScriptRoot Tests) -Show $Show -PesterOption @{ IncludeVSCodeMarker = $IncludeVSCodeMarker }
38+
Invoke-Pester ./Tests -Show $Show -PesterOption @{ IncludeVSCodeMarker = $IncludeVSCodeMarker }
3939
}
4040

4141
Pop-Location

0 commit comments

Comments
 (0)