From fb60c47a1ecbca2a6f287e0626a372497112f0a3 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Mon, 11 Sep 2017 15:24:09 -0700 Subject: [PATCH] Fix travis-ci script so that PRs can fail due to pester tests (#4807) --- tools/travis.ps1 | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index f694a18829..b1116934ec 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -175,6 +175,17 @@ else $pesterPassThruObject = Start-PSPester @pesterParam + # Determine whether the build passed + try { + # this throws if there was an error + Test-PSPesterResults -ResultObject $pesterPassThruObject + $result = "PASS" + } + catch { + $resultError = $_ + $result = "FAIL" + } + if (-not $isPr) { # Run 'CrossGen' for push commit, so that we can generate package. # It won't rebuild powershell, but only CrossGen the already built assemblies. @@ -203,16 +214,6 @@ else } } - # Determine whether the build passed - try { - # this throws if there was an error - Test-PSPesterResults -ResultObject $pesterPassThruObject - $result = "PASS" - } - catch { - $resultError = $_ - $result = "FAIL" - } # update the badge if you've done a cron build, these are not fatal issues if ( $cronBuild ) { try { @@ -229,10 +230,11 @@ else Write-Warning "Could not update status badge: $_" } } - # if the tests did not pass, throw the reason why - if ( $result -eq "FAIL" ) { - Throw $resultError - } + } + + # if the tests did not pass, throw the reason why + if ( $result -eq "FAIL" ) { + Throw $resultError } Start-PSxUnit