Skip to content

Commit 930f394

Browse files
corbobAdmiringWorm
authored andcommitted
(maint) Output choco pack failures
This adds logic to the Invoke-Tests file to output if a package failed fail to pack. This allows for improved developer experience by indicating if packages fail to build. This also allows impromptu improvement to the developer experience by allowing simple changes to the script to throw in place of outputting an errorand thus not allowing tests to run without the full set of test packages.
1 parent a93c0c4 commit 930f394

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

Invoke-Tests.ps1

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,30 @@ if (-not (Test-Path "$TestPath/packages") -or -not $SkipPackaging) {
5757
$nuspecs = Get-ChildItem -Path $PSScriptRoot/src/chocolatey.tests.integration, $PSScriptRoot/tests/packages -Recurse -Include *.nuspec | Where-Object FullName -NotMatch 'bin'
5858
Get-ChildItem -Path $PSScriptRoot/tests/packages -Recurse -Include *.nupkg | Copy-Item -Destination "$TestPath/packages"
5959

60-
foreach ($file in $nuspecs) {
61-
Write-Host "Packaging $file"
60+
$packFailures = foreach ($file in $nuspecs) {
6261
# Include allow-unofficial in case an unofficial Chocolatey has been installed globally for testing
63-
$null = choco pack $file.FullName --out "$TestPath/packages" --allow-unofficial
62+
$packOutput = choco pack $file.FullName --out "$TestPath/packages" --allow-unofficial
63+
if ($LASTEXITCODE -ne 0) {
64+
[pscustomobject]@{
65+
Package = $file.FullName
66+
ExitCode = $LASTEXITCODE
67+
Output = $packOutput
68+
}
69+
Write-Warning "Failed to pack $file"
70+
}
71+
else {
72+
Write-Host "Packaged $file"
73+
}
74+
}
75+
76+
if ($null -ne $packFailures) {
77+
foreach ($failure in $packFailures) {
78+
Write-Warning "$($failure.Package) failed to pack with exit code: $($failure.ExitCode)"
79+
$failure.Output | Write-Warning
80+
}
81+
# If you want to stop things, change this to a throw.
82+
# This is not currently throwing as there are two packages that are supposed to fail.
83+
Write-Error "$($packFailures.Count) packages failed to pack."
6484
}
6585
}
6686

0 commit comments

Comments
 (0)