Commit f501644
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>1 parent 1ae2cd9 commit f501644
1 file changed
Lines changed: 9 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 | + | |
17 | 24 | | |
18 | | - | |
19 | | - | |
| 25 | + | |
| 26 | + | |
20 | 27 | | |
21 | 28 | | |
22 | 29 | | |
| |||
0 commit comments