diff --git a/build.psm1 b/build.psm1 index afcc738de2..27df1f3d7c 100644 --- a/build.psm1 +++ b/build.psm1 @@ -667,7 +667,8 @@ function Start-PSPester { [string]$binDir = (Split-Path (New-PSOptions -FullCLR:$FullCLR).Output), [string]$powershell = (Join-Path $binDir 'powershell'), [string]$Pester = ([IO.Path]::Combine($binDir, "Modules", "Pester")), - [switch]$Unelevate + [switch]$Unelevate, + [switch]$Quiet ) # we need to do few checks and if user didn't provide $ExcludeTag explicitly, we should alternate the default @@ -726,6 +727,11 @@ function Start-PSPester { if ($Tag) { $Command += "-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 " + } $Command += "'" + $Path + "'" if ($Unelevate) @@ -799,6 +805,17 @@ function script:Start-UnelevatedProcess runas.exe /trustlevel:0x20000 "$process $arguments" } +function Show-PSPesterError +{ + param ( [Xml.XmlElement]$testFailure ) + logerror ("Description: " + $testFailure.description) + logerror ("Name: " + $testFailure.name) + logerror "message:" + logerror $testFailure.failure.message + logerror "stack-trace:" + logerror $testFailure.failure."stack-trace" +} + # # Read the test result file and # Throw if a test failed @@ -806,7 +823,7 @@ function Test-PSPesterResults { param( [string]$TestResultsFile = "pester-tests.xml", - [string] $TestArea = 'test/powershell' + [string]$TestArea = 'test/powershell' ) if(!(Test-Path $TestResultsFile)) @@ -817,6 +834,11 @@ function Test-PSPesterResults $x = [xml](Get-Content -raw $testResultsFile) if ([int]$x.'test-results'.failures -gt 0) { + logerror "TEST FAILURES" + foreach ( $testfail in $x.SelectNodes('.//test-case[@result = "Failure"]')) + { + Show-PSPesterError $testfail + } throw "$($x.'test-results'.failures) tests in $TestArea failed" } } @@ -2053,6 +2075,12 @@ function script:log([string]$message) { [console]::ResetColor() } +function script:logerror([string]$message) { + Write-Host -Foreground Red $message + #reset colors for older package to at return to default after error message on a compilation error + [console]::ResetColor() +} + function script:precheck([string]$command, [string]$missedMessage) { $c = Get-Command $command -ErrorAction SilentlyContinue if (-not $c) { diff --git a/tools/travis.ps1 b/tools/travis.ps1 index ba5a9c6788..577ea19126 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -17,6 +17,13 @@ $pesterParam = @{ 'binDir' = $output } if ($isFullBuild) { $pesterParam['Tag'] = @('CI','Feature','Scenario') $pesterParam['ExcludeTag'] = @() + # cron jobs create log files which include the stdout of Pester + # which creates too much data for travis to put in the log file + # and the job is then cancelled. Add Quiet to reduce the log size + # the xunit log created by pester is what is important + if ( $env:TRAVIS_EVENT_TYPE -eq 'cron' ) { + $pesterParam['Quiet'] = $true + } } else { $pesterParam['Tag'] = @('CI') $pesterParam['ThrowOnFailure'] = $true