Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
c6b35ab
Migrate Pester tests from v4 to v5
nohwnd Apr 17, 2026
48231f5
Fix duplicate Run key in PesterConfiguration hashtable
nohwnd Apr 17, 2026
b17e620
Fix UpdatableHelpSystem.Tests.ps1 discovery/runtime scope bugs
nohwnd Jun 10, 2026
cc9fd83
Fix Pester 5 scope bugs in 3 more test files
nohwnd Jun 10, 2026
61a39bd
Fix Pester 5 scope bugs and -ErrorId matching in more test files
nohwnd Jun 10, 2026
1eb8031
Fix Pester 5 discovery and skip patterns in 2 more test files
nohwnd Jun 10, 2026
5ceb729
Restore ErrorView squiggles and fix SemanticVersion BeforeAll/BeforeD…
nohwnd Jun 10, 2026
0f6115c
Fix Pester 5 discovery/runtime scope issues in remoting+misc tests
nohwnd Jun 10, 2026
bc3caeb
Pester 5: discovery-scope and TestCases fixes for two Windows-elevate…
nohwnd Jun 10, 2026
570cc51
Pester 5: top-level skip, $script: scope, and assertion operator fixe…
nohwnd Jun 11, 2026
1e34a35
Pester 5: round 9 - cross-platform scope and assertion fixes
nohwnd Jun 11, 2026
5bbbd5d
Pester 5: round 10 - Windows-elevated and helper-function fixes
nohwnd Jun 11, 2026
7d1665e
Pester 5: fix PSSessionConfiguration RegisterNewConfiguration null path
nohwnd Jun 11, 2026
8052c78
Pester 5: avoid Join-Path on TestDrive PSDrive during discovery
nohwnd Jun 11, 2026
11777d1
Pester 5: round 12 - top-level helper functions + runtime $script: re…
nohwnd Jun 11, 2026
afa59fc
Pester 5: round 13 - merge duplicate BeforeAll blocks (only last runs…
nohwnd Jun 11, 2026
d0fdf06
Pester 5: round 14 - move Describe-level skips out of BeforeAll, wrap…
nohwnd Jun 11, 2026
70abda3
Pester 5: round 15 - sweep anti-patterns #26 (skip-in-BeforeAll too l…
nohwnd Jun 11, 2026
5c306b0
Pester 5: round 16 - fix anti-pattern #28 (file-scope it:skip leaking…
nohwnd Jun 11, 2026
718f15a
Pester 5: round 17 - WSL-validated batch fix across 12 test files
nohwnd Jun 11, 2026
5845d4e
Pester 5: round 18 - redefine ConvertTo-Hashtable inside DefaultComma…
nohwnd Jun 11, 2026
5f4d6b5
test(pester5): r19 — anti-pattern #26 Linux/macOS skip batch
nohwnd Jun 11, 2026
fb1d344
Pester 5 migration round 20 - 5 files (next-tier residuals)
nohwnd Jun 11, 2026
8a8f4e7
Pester 5 migration round 21 - AP23 in 2 Windows-only test files
nohwnd Jun 11, 2026
320b503
Pester 5 migration round 22 - 5 file-targeted fixes
nohwnd Jun 11, 2026
aae995e
Pester 5 migration round 23 - WinRM / IsWindows discovery-time skips
nohwnd Jun 11, 2026
5c725d9
Pester 5 migration round 24 - Implicit.Remoting probe + product Pendi…
nohwnd Jun 11, 2026
a45cba5
Pester 5 migration round 25 - fix discovery regression from round 24
nohwnd Jun 11, 2026
e3b0eb3
Pester 5: round 26 local iteration fixes (5 files)
nohwnd Jun 11, 2026
9c71333
Pester 5 migration round 27 — Implicit.Remoting AP31 fix + WebCmdlets
nohwnd Jun 11, 2026
0ca4227
Pester 5 migration round 28 - skip platform-specific product issues
nohwnd Jun 12, 2026
39d6ef7
Pester 5 migration round 29 — drop redundant runtime skipTest guards …
nohwnd Jun 12, 2026
f501efc
Pester 5 migration round 30 — discovery-time skip & TestCases interpo…
nohwnd Jun 12, 2026
5612681
Pester 5: fix UsingAssembly $script: scope, restore LocalAccounts dis…
nohwnd Jun 12, 2026
e09ab40
Pester 5: restore AfterAll in Format-Custom DRT Describe to unbreak $…
nohwnd Jun 12, 2026
e5d2d32
Pester 5: fix WinCompat $script:desktopModuleToUse and symlink Before…
nohwnd Jun 12, 2026
e32628f
Pester 5: keep wsman: drive globally scoped after remove/re-add test
nohwnd Jun 12, 2026
d5fe310
Pester 5: fix Test-Path NUL TestCases truncating junit XML; clean up …
nohwnd Jun 12, 2026
f89fc06
Pester 5: shallow-project PassThru before Export-Clixml; skip 2 Get-H…
nohwnd Jun 12, 2026
df5d5a1
Clean up merge artifacts and global variable pollution
nohwnd Jun 16, 2026
4d940b4
Remove unnecessary platform skips, fix helpFunc12 syntax test
nohwnd Jun 16, 2026
dba8a6b
Fix NativeStreams and SuppressAnsi cross-file PSStyle pollution
nohwnd Jun 16, 2026
476192e
Fix ProxyCommand.GetHelpComments for environments with installed help
nohwnd Jun 16, 2026
016e0aa
Add AfterAll to restore OutputRendering after Allow Escape Sequences
nohwnd Jun 17, 2026
3eb09fe
Fix NativeStreams tests for corrupted ErrorRecord format view
nohwnd Jun 17, 2026
221cbc4
Replace $global: bridge with -ForEach in DefaultCommands.Tests
nohwnd Jun 17, 2026
48427fb
Use Start-Process for stderr redirect test to bypass ErrorRecord form…
nohwnd Jun 17, 2026
2ca6ba8
Address review: restore SemanticVersion invalid cases, dedupe data, f…
nohwnd Jun 29, 2026
e2a69a2
SemanticVersion: keep lenient-parse cases dropped, trim duplicate run…
nohwnd Jun 29, 2026
9d10f4c
Dedup ConvertTo-Hashtable in DefaultCommands.Tests.ps1
nohwnd Jun 29, 2026
47c6f7d
Reference tracking issue #27642 in macOS skip comments
nohwnd Jun 29, 2026
e2d1b65
Bump to Pester 6.0.0 and apply v6 compatibility fixes
nohwnd Jul 7, 2026
23875d1
Fix Pester 6 OOM in Encoding.Tests: pass command name, not CommandInfo
nohwnd Jul 7, 2026
f4cbb15
Convert It -Pending to -Skip for Pester 6
nohwnd Jul 7, 2026
ff81a91
Fix ErrorView ConciseView test for Pester 6 TestDrive naming
nohwnd Jul 7, 2026
e234b86
Skip unreliable untrusted-module import at discovery for Pester 6
nohwnd Jul 7, 2026
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
77 changes: 62 additions & 15 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1139,17 +1139,17 @@ function Restore-PSPester
{
<#
.SYNOPSIS
Downloads and saves the Pester module (v4.x) from the PowerShell Gallery.
Downloads and saves the Pester module (v6.x) from the PowerShell Gallery.
.DESCRIPTION
Uses Save-Module to install Pester up to version 4.99 into the target directory.
Uses Save-Module to install Pester version 6.0.0 into the target directory.
.PARAMETER Destination
Directory to save Pester into. Defaults to the Modules folder of the current build output.
#>
param(
[ValidateNotNullOrEmpty()]
[string] $Destination = ([IO.Path]::Combine((Split-Path (Get-PSOptions -DefaultToNew).Output), "Modules"))
)
Save-Module -Name Pester -Path $Destination -Repository PSGallery -MaximumVersion 4.99
Save-Module -Name Pester -Path $Destination -Repository PSGallery -RequiredVersion 6.0.0
}

function Compress-TestContent {
Expand Down Expand Up @@ -1737,7 +1737,7 @@ function Start-PSPester {
Switch-PSNugetConfig -Source Public
}

if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge "4.2" } ))
if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge "5.0" } ))
{
Restore-PSPester
}
Expand Down Expand Up @@ -1838,25 +1838,36 @@ function Start-PSPester {
}
}

$command += "Invoke-Pester "
$runProps = "Path = @('" + ($Path -join "','") + "')"
if ( $PassThru ) {
$runProps += "; PassThru = `$true"
}
# Pester 6 fails discovery on an empty/`$null -ForEach or -TestCases by default.
# Keep the Pester 5 behavior (empty set = zero tests, no error) for this suite.
$runProps += "; FailOnNullOrEmptyForEach = `$false"

$command += "`$pesterConfig = [PesterConfiguration]@{"
$command += " Run = @{ ${runProps} }"
$command += "; TestResult = @{ Enabled = `$true; OutputPath = '${OutputFile}'; OutputFormat = '${OutputFormat}' }"

$command += "-OutputFormat ${OutputFormat} -OutputFile ${OutputFile} "
if ($ExcludeTag -and ($ExcludeTag -ne "")) {
$command += "-ExcludeTag @('" + (${ExcludeTag} -join "','") + "') "
$command += "; Filter = @{ ExcludeTag = @('" + (${ExcludeTag} -join "','") + "')"
if ($Tag) {
$command += "; Tag = @('" + (${Tag} -join "','") + "')"
}
$command += " }"
}
if ($Tag) {
$command += "-Tag @('" + (${Tag} -join "','") + "') "
elseif ($Tag) {
$command += "; Filter = @{ Tag = @('" + (${Tag} -join "','") + "') }"
}

# sometimes we need to eliminate Pester output, especially when we're
# doing a daily build as the log file is too large
if ( $Quiet ) {
$command += "-Quiet "
}
if ( $PassThru ) {
$command += "-PassThru "
$command += "; Output = @{ Verbosity = 'None' }"
}

$command += "'" + ($Path -join "','") + "'"
$command += " }; Invoke-Pester -Configuration `$pesterConfig"
if ($Unelevate)
{
$command += " *> $outputBufferFilePath; '__UNELEVATED_TESTS_THE_END__' >> $outputBufferFilePath"
Expand Down Expand Up @@ -2012,7 +2023,43 @@ function Start-PSPester {

try
{
$command += "| Export-Clixml -Path '$passThruFile' -Force"
# Project the Pester PassThru object down to a shallow PSCustomObject before
# Export-Clixml. Pester 5's Run object has a deeply nested tree of containers,
# blocks, tests and ScriptBlock references; serializing it produces a CliXml
# graph that exceeds the deserializer's hard MaxDepthBelowTopLevel of 50
# (see src/System.Management.Automation/engine/serialization.cs) and crashes
# Import-Clixml with "Serialized XML is nested too deeply." The downstream
# consumer (Test-PSPesterResults) only reads TotalCount, FailedCount and
# iterates TestResult; the full per-test details are already printed to the
# console by Pester and captured in the NUnit XML, so projecting them away
# here is safe. Failed test details are preserved in TestResult so that
# Show-PSPesterError -testFailureObject continues to print a useful summary.
$projection = '| ForEach-Object { ' + `
'$run = $_; ' + `
'$failed = @(); ' + `
'if ($null -ne $run.Tests) { ' + `
'$failed = @($run.Tests | Where-Object { -not $_.Passed } | ForEach-Object { ' + `
'[pscustomobject]@{ ' + `
'Passed = $false; ' + `
'Describe = $(if ($_.Block -and $_.Block.Path) { ($_.Block.Path -join ''/'') } else { '''' }); ' + `
'Context = ''''; ' + `
'Name = [string]$_.Name; ' + `
'FailureMessage = $(if ($_.ErrorRecord) { (($_.ErrorRecord | ForEach-Object { $_.ToString() }) -join [Environment]::NewLine) } else { '''' }); ' + `
'StackTrace = $(if ($_.ErrorRecord -and $_.ErrorRecord.Count -gt 0 -and $_.ErrorRecord[0].ScriptStackTrace) { [string]$_.ErrorRecord[0].ScriptStackTrace } else { '''' }) ' + `
'} ' + `
'}) ' + `
'}; ' + `
'[pscustomobject]@{ ' + `
'TotalCount = [int]$run.TotalCount; ' + `
'FailedCount = [int]$run.FailedCount; ' + `
'PassedCount = [int]$run.PassedCount; ' + `
'SkippedCount = [int]$run.SkippedCount; ' + `
'NotRunCount = [int]$run.NotRunCount; ' + `
'InconclusiveCount = [int]$run.InconclusiveCount; ' + `
'TestResult = $failed ' + `
'} ' + `
'}'
$command += "$projection | Export-Clixml -Path '$passThruFile' -Force"

$passThruCommand = { & $powershell $PSFlags -c $command }
if ($Sudo.IsPresent) {
Expand Down
Loading
Loading