Skip to content

Commit 2ffd174

Browse files
committed
ci: fix Pester integration test failing in BeforeAll/AfterAll
The dynamic `-Skip:(-not $script:isWindows)` on the `It` block was evaluated during Pester discovery, before `BeforeAll` had run, so the variable was always `$null` and the skip expression always `$true`. That cascaded into the `AfterAll` calling `Test-Path -LiteralPath $null` which throws ArgumentNullException — the failure surface in CI. Remove the dynamic skip (the `-Tag 'Integration','Windows'` on the Describe already lets non-Windows local runs filter it out via `-ExcludeTag`), and guard the AfterAll cleanup against a null path.
1 parent ccb9d2d commit 2ffd174

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

scripts/tests/BuildLauncher.Tests.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,15 @@ Describe 'build-launcher.ps1 — parameter sets' {
7676
}
7777

7878
Describe 'build-launcher.ps1 — dry-run with -SkipSign' -Tag 'Integration', 'Windows' {
79+
# Skip the whole Describe on non-Windows (no csc.exe shipped). The
80+
# `-Tag` lets CI on Windows run this; local Pester runs on macOS/Linux
81+
# filter with `-ExcludeTag Windows`.
82+
7983
BeforeAll {
80-
$script:isWindows = $IsWindows -or [Environment]::OSVersion.Platform -eq 'Win32NT'
81-
$script:tempOut = Join-Path ([IO.Path]::GetTempPath()) ("cct-build-" + [Guid]::NewGuid())
84+
$script:tempOut = Join-Path ([IO.Path]::GetTempPath()) ("cct-build-" + [Guid]::NewGuid())
8285
}
8386

84-
It 'produces claude-code-install-manager.exe and SHA256SUMS' -Skip:(-not $script:isWindows) {
87+
It 'produces claude-code-install-manager.exe and SHA256SUMS' {
8588
& $script:buildPs1 -OutDir $script:tempOut -SkipSign | Out-Null
8689
$LASTEXITCODE | Should -BeIn 0, $null
8790

@@ -95,7 +98,7 @@ Describe 'build-launcher.ps1 — dry-run with -SkipSign' -Tag 'Integration', 'Wi
9598
}
9699

97100
AfterAll {
98-
if (Test-Path -LiteralPath $script:tempOut) {
101+
if ($script:tempOut -and (Test-Path -LiteralPath $script:tempOut)) {
99102
Remove-Item -LiteralPath $script:tempOut -Recurse -Force -ErrorAction SilentlyContinue
100103
}
101104
}

0 commit comments

Comments
 (0)