Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -799,14 +805,25 @@ 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
function Test-PSPesterResults
{
param(
[string]$TestResultsFile = "pester-tests.xml",
[string] $TestArea = 'test/powershell'
[string]$TestArea = 'test/powershell'
)

if(!(Test-Path $TestResultsFile))
Expand All @@ -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"
}
}
Expand Down Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions tools/travis.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down