Commit 03b9864
fix(build): target staged output for code coverage (#19)
* fix(build): target staged output for code coverage
Pester reports 0% coverage on every module scaffolded from this template
because the coverage globs point at the source tree
(`{{ModuleName}}/{Public,Private}/*.ps1`) but the test files
Import-Module from the staged build output (`Output/<Name>/<Version>/`).
Pester treats the two paths as different files, so every executed line
counts as "missed."
The natural fix — using `$Env:BHBuildOutput` directly — does not work:
PowerShellBuild only rewrites that variable to the staged version path
later, inside its own tasks. At psake `properties`-evaluation time,
`$Env:BHBuildOutput` is still BuildHelpers' default `<root>/BuildOutput`,
which doesn't exist yet and would cause Pester to bail with
"Could not resolve coverage path."
Compute the staged path explicitly from the manifest version (read via
`$Env:BHPSModuleManifest`, which BuildHelpers populates before psake
runs). This also drops the `{{ModuleName}}` placeholder from the
coverage section entirely, since the path is now derived from the
already-substituted BuildHelpers env vars.
Verified downstream in JsmOperations: Pester goes from 0% / 75% to
100% / 75% on the same test suite, with no test changes.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
* fix(build): guard coverage env vars and normalize path style
Address PR #19 review feedback:
- Guard against missing $Env:BHPSModuleManifest / $Env:BHProjectName so
bypassing build.ps1 (and Set-BuildEnvironment) fails fast with an
actionable message instead of an obscure Import-PowerShellDataFile
null-binding error. (Copilot review)
- Switch the staged-output assembly from Join-Path with embedded
forward slashes to [IO.Path]::Combine to match the rest of the
properties block and avoid mixed separators on Windows. (CodeRabbit
review)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1ae2cd9 commit 03b9864
1 file changed
Lines changed: 12 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
17 | 27 | | |
18 | | - | |
19 | | - | |
| 28 | + | |
| 29 | + | |
20 | 30 | | |
21 | 31 | | |
22 | 32 | | |
| |||
0 commit comments