diff --git a/build.psm1 b/build.psm1 index de75b1c15..8da8646e0 100644 --- a/build.psm1 +++ b/build.psm1 @@ -824,6 +824,7 @@ function Start-PSPester { [Parameter(ParameterSetName='Unelevate',Mandatory=$true)] [switch]$Unelevate, [switch]$Quiet, + [switch]$Terse, [Parameter(ParameterSetName='PassThru',Mandatory=$true)] [switch]$PassThru, [switch]$IncludeFailingTest @@ -865,6 +866,10 @@ function Start-PSPester { # All concatenated commands/arguments are suffixed with the delimiter (space) $Command = "" + if ($Terse) + { + $Command += "`$ProgressPreference = 'silentlyContinue'; " + } # Autoload (in subprocess) temporary modules used in our tests $Command += '$env:PSModulePath = '+"'$TestModulePath$TestModulePathSeparator'" + '+$($env:PSModulePath);' @@ -907,6 +912,49 @@ function Start-PSPester { Write-Verbose $Command + $script:nonewline = $true + $script:inerror = $false + function Write-Terse([string] $line) + { + $trimmedline = $line.Trim() + if ($trimmedline.StartsWith("[+]")) { + Write-Host "+" -NoNewline -ForegroundColor Green + $script:nonewline = $true + $script:inerror = $false + } + elseif ($trimmedline.StartsWith("[?]")) { + Write-Host "?" -NoNewline -ForegroundColor Cyan + $script:nonewline = $true + $script:inerror = $false + } + elseif ($trimmedline.StartsWith("[!]")) { + Write-Host "!" -NoNewline -ForegroundColor Gray + $script:nonewline = $true + $script:inerror = $false + } + else { + if ($script:nonewline) { + Write-Host "`n" -NoNewline + } + if ($trimmedline.StartsWith("[-]") -or $script:inerror) { + Write-Host $line -ForegroundColor Red + $script:inerror = $true + } + elseif ($trimmedline.StartsWith("VERBOSE:")) { + Write-Host $line -ForegroundColor Yellow + $script:inerror = $false + } + elseif ($trimmedline.StartsWith("Describing") -or $trimmedline.StartsWith("Context")) { + Write-Host $line -ForegroundColor Magenta + $script:inerror = $false + } + else { + Write-Host $line -ForegroundColor Gray + } + $script:nonewline = $false + } + } + # To ensure proper testing, the module path must not be inherited by the spawned process try { $originalModulePath = $env:PSModulePath @@ -917,7 +965,17 @@ function Start-PSPester { while ($true) { $lines = Get-Content $outputBufferFilePath | Select-Object -Skip $currentLines - $lines | Write-Host + if ($Terse) + { + foreach ($line in $lines) + { + Write-Terse -line $line + } + } + else + { + $lines | Write-Host + } if ($lines | Where-Object { $_ -eq '__UNELEVATED_TESTS_THE_END__'}) { break @@ -942,7 +1000,14 @@ function Start-PSPester { try { $Command += "|Export-Clixml -Path '$passThruFile' -Force" - Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Host $_} + if ($Terse) + { + Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Terse $_} + } + else + { + Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Host $_} + } Import-Clixml -Path $passThruFile | Where-Object {$_.TotalCount -is [Int32]} } finally @@ -952,7 +1017,14 @@ function Start-PSPester { } else { - Start-NativeExecution -sb {& $powershell -noprofile -c $Command} + if ($Terse) + { + Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Terse -line $_ } + } + else + { + Start-NativeExecution -sb {& $powershell -noprofile -c $Command} + } } } } finally { diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index d859a2c1e..58a9ee402 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -348,11 +348,11 @@ function Invoke-AppVeyorTest Remove-Item -Force ${telemetrySemaphoreFilepath} } - Start-PSPester -bindir $env:CoreOutput -outputFile $testResultsNonAdminFile -Unelevate -Tag @() -ExcludeTag ($ExcludeTag + @('RequireAdminOnWindows')) + Start-PSPester -Terse -bindir $env:CoreOutput -outputFile $testResultsNonAdminFile -Unelevate -Tag @() -ExcludeTag ($ExcludeTag + @('RequireAdminOnWindows')) Write-Host -Foreground Green 'Upload CoreCLR Non-Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsNonAdminFile - Start-PSPester -bindir $env:CoreOutput -outputFile $testResultsAdminFile -Tag @('RequireAdminOnWindows') -ExcludeTag $ExcludeTag + Start-PSPester -Terse -bindir $env:CoreOutput -outputFile $testResultsAdminFile -Tag @('RequireAdminOnWindows') -ExcludeTag $ExcludeTag Write-Host -Foreground Green 'Upload CoreCLR Admin test results' Update-AppVeyorTestResults -resultsFile $testResultsAdminFile diff --git a/tools/travis.ps1 b/tools/travis.ps1 index d1cf06fde..2b3281e68 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -158,6 +158,7 @@ else $pesterParam = @{ 'binDir' = $output 'PassThru' = $true + 'Terse' = $true } if ($isFullBuild) {