Skip to content

test: Add Test-PSBuildPester integration tests and fix latent bugs#137

Merged
tablackburn merged 2 commits into
mainfrom
claude/psake-project-next-item-6mfurr
Jul 10, 2026
Merged

test: Add Test-PSBuildPester integration tests and fix latent bugs#137
tablackburn merged 2 commits into
mainfrom
claude/psake-project-next-item-6mfurr

Conversation

@tablackburn

Copy link
Copy Markdown
Contributor

Summary

Implements #102 — integration tests for Test-PSBuildPester, the module's most regression-prone function — and fixes two latent bugs the tests exposed, test-first (all 14 tests red before the fixes, green after).

Tests (tests/Test-PSBuildPester.tests.ps1):

Fixes in Test-PSBuildPester.ps1 (both changelogged under Unreleased):

  1. The finally block called Remove-Module with an empty -Name when the optional ModuleName parameter was omitted — a parameter-binding error that -ErrorAction SilentlyContinue cannot suppress, so any run without -ModuleName errored after tests completed
  2. An unconditional Import-Module Pester -MinimumVersion 5.0.0 loaded the newest installed Pester on top of an already-loaded one, crashing with a Pester.dll version conflict when 5.x and 6.x are installed side by side. The function now respects a loaded Pester (with a clear localized error below 5.0.0) and imports the newest installed version only when none is loaded — which is also what makes the version-pinned test matrix possible

Test Plan

  • Red phase: all 14 new tests fail against the unfixed function (ModuleName binding error everywhere; dll clash on the 5.x legs)
  • Green phase: 14/14 pass after the fixes
  • Full suite green locally under Pester 6.0.0: 391 passed, 0 failed, 15 skipped
  • CI matrix green (ubuntu / windows pwsh / windows PowerShell 5.1 / macOS)

Breaking Changes

None. Behavior change by design: Test-PSBuildPester no longer force-upgrades the in-session Pester to the newest installed version — consumers who load a specific Pester 5.x before running tasks now keep it.

🤖 Generated with Claude Code

https://claude.ai/code/session_011semwa5HU1BUKKL4RoWjKa


Generated by Claude Code

Add tests/Test-PSBuildPester.tests.ps1 (#102).
Every invocation runs in a Start-Job subprocess with a pinned inner
Pester version, and the scenarios run against both installed Pester
majors (5.x and 6.x) to verify the shipped function keeps supporting
Pester 5 consumers. Crash fixtures are generated into $TestDrive at
runtime, never checked in. Scenarios: healthy suite, failing test
(regression #52), BeforeAll crash and discovery crash (#128/#133 gate),
NUnit result output, and code coverage output path/format (regression
Add a second, named Pester dependency (PesterLegacy, 5.9.0) to
requirements.psd1 so CI installs both majors side by side.

Fix two latent Test-PSBuildPester bugs the tests exposed, test-first
(all 14 tests failed before the fixes, pass after):

- The finally block called Remove-Module with an empty -Name when the
  optional ModuleName parameter was omitted, raising a parameter-
  binding error that -ErrorAction SilentlyContinue cannot suppress.
- An unconditional Import-Module Pester -MinimumVersion 5.0.0 loaded
  the newest installed Pester on top of an already-loaded one, which
  crashes with a Pester.dll version conflict when two versions are
  installed side by side. The function now respects a loaded Pester
  (with a clear error below 5.0.0) and imports the newest installed
  version only when none is loaded.

Closes #102

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011semwa5HU1BUKKL4RoWjKa
Copilot AI review requested due to automatic review settings July 10, 2026 04:57
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown

Test Results

    4 files  ± 0    664 suites  +12   2m 19s ⏱️ + 1m 58s
  405 tests +14    403 ✅ +14   2 💤 ±0  0 ❌ ±0 
1 624 runs  +56  1 577 ✅ +56  47 💤 ±0  0 ❌ ±0 

Results for commit fcf79ad. ± Comparison against base commit 82532a3.

♻️ This comment has been updated with latest results.

The bootstrap runs Invoke-PSDepend with -Import, which imports every
dependency into the bootstrap session. With two Pester majors in
requirements.psd1 that crashed every CI leg with a Pester.dll version
conflict before any task ran.

Move the matrix-only Pester 5.9.0 into requirements.pester-matrix.psd1
and install it with a second, import-free Invoke-PSDepend call. The
main requirements file keeps a single Pester entry, so the bootstrap
session only ever imports one Pester version.

Verified with the exact CI command (./build.ps1 -Bootstrap -Task Test):
391 passed, 0 failed.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011semwa5HU1BUKKL4RoWjKa

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds integration tests around Test-PSBuildPester (the task’s most regression-prone wrapper around Invoke-Pester) and hardens the task against two real-world failure modes that show up when multiple Pester majors are installed.

Changes:

  • Added a new integration test suite that runs Test-PSBuildPester in isolated Start-Job subprocesses and validates behavior across installed Pester 5.x and 6.x.
  • Updated Test-PSBuildPester to (1) respect an already-loaded Pester module and (2) avoid Remove-Module parameter-binding errors when -ModuleName is omitted.
  • Pinned an additional side-by-side Pester 5 dependency (PesterLegacy) to support the test matrix, plus localized messaging and changelog entries for the fixes.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/Test-PSBuildPester.tests.ps1 Adds job-isolated integration tests covering pass/fail/crash/output/coverage scenarios across Pester majors.
requirements.psd1 Adds PesterLegacy (Pester 5.9.0) alongside Pester 6.0.0 to enable multi-major validation in CI.
PowerShellBuild/Public/Test-PSBuildPester.ps1 Fixes two latent bugs: avoid re-importing Pester over an already-loaded version; avoid Remove-Module binding errors when ModuleName is empty.
PowerShellBuild/PowerShellBuild.psm1 Adds localized message key for the “Pester too old” error.
PowerShellBuild/en-US/Messages.psd1 Adds the en-US localized message for unsupported Pester versions.
CHANGELOG.md Documents both fixes under Unreleased.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@tablackburn tablackburn merged commit 3cd758e into main Jul 10, 2026
9 checks passed
@tablackburn tablackburn deleted the claude/psake-project-next-item-6mfurr branch July 10, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants