Skip to content

Commit 87127e4

Browse files
committed
fix(tests): bootstrap BuildHelpers env before Invoke-psake in test files
1 parent 385c33e commit 87127e4

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

tests/Help.tests.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ BeforeDiscovery {
6969
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
7070
build the module. #>
7171
if ($null -eq $Env:BHBuildOutput) {
72+
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
73+
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
74+
# via ./build.ps1 this happens before psake; running tests in isolation
75+
# bypasses that, so we do it here.
76+
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
7277
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
7378
$invokePsakeParameters = @{
7479
TaskList = 'Build'
@@ -122,6 +127,11 @@ BeforeAll {
122127
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
123128
build the module. #>
124129
if ($null -eq $Env:BHBuildOutput) {
130+
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
131+
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
132+
# via ./build.ps1 this happens before psake; running tests in isolation
133+
# bypasses that, so we do it here.
134+
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
125135
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
126136
$invokePsakeParameters = @{
127137
TaskList = 'Build'

tests/Manifest.tests.ps1

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ BeforeDiscovery {
3232
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
3333
build the module. #>
3434
if ($null -eq $Env:BHBuildOutput) {
35+
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
36+
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
37+
# via ./build.ps1 this happens before psake; running tests in isolation
38+
# bypasses that, so we do it here.
39+
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
3540
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
3641
$invokePsakeParameters = @{
3742
TaskList = 'Build'
@@ -65,6 +70,11 @@ BeforeAll {
6570
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
6671
build the module. #>
6772
if ($null -eq $Env:BHBuildOutput) {
73+
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
74+
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
75+
# via ./build.ps1 this happens before psake; running tests in isolation
76+
# bypasses that, so we do it here.
77+
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
6878
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
6979
$invokePsakeParameters = @{
7080
TaskList = 'Build'

0 commit comments

Comments
 (0)