Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions build.psake.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,19 @@ properties {
$PSBPreference.Test.OutputFile = [IO.Path]::Combine($PSScriptRoot, 'out', 'testResults.xml')
$PSBPreference.Test.OutputFormat = 'NUnitXml'
$PSBPreference.Test.CodeCoverage.Enabled = $true
# Coverage must target the staged build output, not the source tree — tests
# Import-Module from Output/<Name>/<Version>, so Pester only records hits
# against those paths. $Env:BHBuildOutput points at <root>/BuildOutput at
# properties-evaluation time (PowerShellBuild rewrites it later inside its
# tasks), so we compute the staged path from the manifest version here.
if (-not $Env:BHPSModuleManifest -or -not $Env:BHProjectName) {
throw 'Coverage configuration requires BuildHelpers env vars. Run via ./build.ps1 or call Set-BuildEnvironment first.'
Comment thread
tablackburn marked this conversation as resolved.
}
$moduleVersion = (Import-PowerShellDataFile -Path $Env:BHPSModuleManifest).ModuleVersion
$stagedOutput = [IO.Path]::Combine($PSScriptRoot, 'Output', $Env:BHProjectName, $moduleVersion)
$PSBPreference.Test.CodeCoverage.Files = @(
"$PSScriptRoot/PlexAutomationToolkit/Public/*.ps1"
"$PSScriptRoot/PlexAutomationToolkit/Private/*.ps1"
"$stagedOutput/Public/*.ps1"
"$stagedOutput/Private/*.ps1"
)
$PSBPreference.Test.CodeCoverage.Threshold = 0 # Threshold enforced by Codecov
$PSBPreference.Test.CodeCoverage.OutputFile = [IO.Path]::Combine($PSScriptRoot, 'out', 'codeCoverage.xml')
Expand Down
10 changes: 10 additions & 0 deletions tests/Help.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ BeforeDiscovery {
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
build the module. #>
if ($null -eq $Env:BHBuildOutput) {
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
# via ./build.ps1 this happens before psake; running tests in isolation
# bypasses that, so we do it here.
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
$invokePsakeParameters = @{
TaskList = 'Build'
Expand Down Expand Up @@ -122,6 +127,11 @@ BeforeAll {
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
build the module. #>
if ($null -eq $Env:BHBuildOutput) {
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
# via ./build.ps1 this happens before psake; running tests in isolation
# bypasses that, so we do it here.
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
$invokePsakeParameters = @{
TaskList = 'Build'
Expand Down
10 changes: 10 additions & 0 deletions tests/Manifest.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ BeforeDiscovery {
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
build the module. #>
if ($null -eq $Env:BHBuildOutput) {
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
# via ./build.ps1 this happens before psake; running tests in isolation
# bypasses that, so we do it here.
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
$invokePsakeParameters = @{
TaskList = 'Build'
Expand Down Expand Up @@ -65,6 +70,11 @@ BeforeAll {
If the BHBuildOutput environment variable exists, it is running in a psake build, so do not
build the module. #>
if ($null -eq $Env:BHBuildOutput) {
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
# the values it needs (BHPSModuleManifest, BHProjectName) — when running
# via ./build.ps1 this happens before psake; running tests in isolation
# bypasses that, so we do it here.
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
$invokePsakeParameters = @{
TaskList = 'Build'
Expand Down