You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(tests): bootstrap remaining standalone tests via build.ps1 (#39)
* refactor(tests): bootstrap remaining standalone tests via build.ps1
Apply the delegate-to-build.ps1 bootstrap from #38 to the rest of the
test scaffolds: tests/Manifest.tests.ps1 (both BeforeDiscovery and
BeforeAll) and the tests/Unit/ Private and Public templates. These
previously called Invoke-psake against build.psake.ps1 directly without
populating the BuildHelpers env vars its properties block needs, so the
standalone path was broken the same way Help.tests.ps1 was.
Each guard now calls build.ps1 -Task 'Build' -Bootstrap via the call
operator (&), so dependency bootstrap and BuildHelpers environment setup
run through the canonical entry point and the script's terminating exit
is contained to the script boundary instead of ending the Pester run.
Project root is resolved with Split-Path -Parent (one level for
Manifest.tests.ps1, three for the tests/Unit/ files, matching each
file's existing root computation) and a single two-argument Join-Path,
keeping it valid on PowerShell 5.1.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* refactor(tests): compute project root once in bootstrap
Address review feedback (Copilot) on the standalone bootstrap: the
project root was computed twice -- once inline for $buildScript and again
a few lines later for $projectRoot -- which is exactly the kind of
duplication that can drift. Hoist the single $projectRoot assignment
above the BHBuildOutput guard and derive $buildScript from it via
Join-Path, in Manifest.tests.ps1 (both blocks) and the tests/Unit/
Private and Public templates.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ own `CHANGELOG.md` (generated from `CHANGELOG.template.md` during init).
20
20
21
21
- Renamed required PowerShell Gallery publish secret `PS_GALLERY_KEY` → `PSGALLERY_API_KEY` so the secret name matches the env var name PowerShellBuild reads (eliminating the previous mapping caveat). New modules created from the template after this change pick up the new name automatically. **Migration for existing modules:** create a new `PSGALLERY_API_KEY` repo secret with the same value, update `.github/workflows/PublishModuleToPowerShellGallery.yaml` to reference `secrets.PSGALLERY_API_KEY`, then delete the old `PS_GALLERY_KEY` secret.
22
22
- Test scaffolding (`tests/Help.tests.ps1`, `tests/Manifest.tests.ps1`, `tests/Meta.tests.ps1`, `tests/MetaFixers.psm1`, and the `tests/Unit/` templates) no longer names parameters on single-argument calls (e.g. `Test-Path $path`, `Get-Module $name`, `Get-Help $command`), matching the scoped named-parameter rule — name parameters only when a call passes two or more arguments. A trailing switch counts as an argument, so `Split-Path -Path $x -Parent`, `Get-Content -Path $x -Raw`, and `Get-ChildItem -Path $x -Recurse` keep their names, as do genuinely multi-value calls (`Join-Path`, `Get-Command -Name … -CommandType …`) and `Test-Path -LiteralPath`.
23
+
-`tests/Manifest.tests.ps1` and the `tests/Unit/` templates now use the same standalone build-bootstrap approach introduced for `tests/Help.tests.ps1` (#38): their `BHBuildOutput`-missing guards delegate to `build.ps1 -Task 'Build' -Bootstrap` (invoked with `&`, not dot-sourced, so its terminating `exit` is contained) instead of calling `Invoke-psake` against `build.psake.ps1` directly. This routes dependency bootstrap and BuildHelpers environment setup through the canonical entry point, so these tests can be run standalone (e.g. from an editor or by an agent) without first running `./build.ps1`. No effect on CI or `./build.ps1` runs — the guard only fires when `BHBuildOutput` is unset.
0 commit comments