diff --git a/CHANGELOG.md b/CHANGELOG.md index 3157179..00f722c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.0.3] - 2021-06-16 +#### Fixed +* False positives in error handling during package installation for packages that emitted output including the string 'fail' + ## [0.0.3] - 2021-03-28 #### Changed * To mirror broader PowerShell Crescendo support, restrict module to run at a minimum of PowerShell 5.1 diff --git a/src/Foil.ps1 b/src/Foil.ps1 index 84d0ae6..b1061c9 100644 --- a/src/Foil.ps1 +++ b/src/Foil.ps1 @@ -106,7 +106,7 @@ $Commands = @( Handler = { param ($output) if ($output) { - $failures = ($output -match 'fail') + $failures = ($output -match 'Chocolatey installed \d+\/\d+ packages. \d+ packages failed\.') if ($failures) { Write-Error ($output -join "`r`n") } else { diff --git a/src/Foil.psd1 b/src/Foil.psd1 index ac56cef..232bd2b 100644 --- a/src/Foil.psd1 +++ b/src/Foil.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'Foil.psm1' - ModuleVersion = '0.0.3' + ModuleVersion = '0.0.4' GUID = '38430603-9954-45fd-949a-5f79492ffaf7' Author = 'Ethan Bergstrom' Copyright = '2021' diff --git a/test/Foil.tests.ps1 b/test/Foil.tests.ps1 index 1b275bd..4f7997c 100644 --- a/test/Foil.tests.ps1 +++ b/test/Foil.tests.ps1 @@ -130,3 +130,31 @@ Describe "version filters" { } } } + +Describe "error handling on Chocolatey failures" { + $package = 'googlechrome' + # Keep at least one version back, to test the 'latest' feature + $version = '87.0.4280.141' + + AfterAll { + Uninstall-ChocoPackage -Name $package -ErrorAction SilentlyContinue + } + + It 'searches for and fails to silently install a broken package version' { + Get-ChocoPackage -Name $package -Version $version -Exact | Install-ChocoPackage -Force | Should -Throw + } +} + +Describe "avoid false positives in error handling" { + $package = 'Office365Business' + # Keep at least one version back, to test the 'latest' feature + $version = '13901.20336' + + AfterAll { + Uninstall-ChocoPackage -Name $package -ErrorAction SilentlyContinue + } + + It 'searches for and silently installs a specific package version that contains "fail" the output' { + Get-ChocoPackage -Name $package -Version $version -Exact | Install-ChocoPackage -Force | Should -Throw + } +}