@@ -824,6 +824,7 @@ function Start-PSPester {
824
824
[Parameter (ParameterSetName = ' Unelevate' , Mandatory = $true )]
825
825
[switch ]$Unelevate ,
826
826
[switch ]$Quiet ,
827
+ [switch ]$Terse ,
827
828
[Parameter (ParameterSetName = ' PassThru' , Mandatory = $true )]
828
829
[switch ]$PassThru ,
829
830
[switch ]$IncludeFailingTest
@@ -865,6 +866,10 @@ function Start-PSPester {
865
866
866
867
# All concatenated commands/arguments are suffixed with the delimiter (space)
867
868
$Command = " "
869
+ if ($Terse )
870
+ {
871
+ $Command += " `$ ProgressPreference = 'silentlyContinue'; "
872
+ }
868
873
869
874
# Autoload (in subprocess) temporary modules used in our tests
870
875
$Command += ' $env:PSModulePath = ' + " '$TestModulePath$TestModulePathSeparator '" + ' +$($env:PSModulePath);'
@@ -907,6 +912,49 @@ function Start-PSPester {
907
912
908
913
Write-Verbose $Command
909
914
915
+ $script :nonewline = $true
916
+ $script :inerror = $false
917
+ function Write-Terse ([string ] $line )
918
+ {
919
+ $trimmedline = $line.Trim ()
920
+ if ($trimmedline.StartsWith (" [+]" )) {
921
+ Write-Host " +" - NoNewline - ForegroundColor Green
922
+ $script :nonewline = $true
923
+ $script :inerror = $false
924
+ }
925
+ elseif ($trimmedline.StartsWith (" [?]" )) {
926
+ Write-Host " ?" - NoNewline - ForegroundColor Cyan
927
+ $script :nonewline = $true
928
+ $script :inerror = $false
929
+ }
930
+ elseif ($trimmedline.StartsWith (" [!]" )) {
931
+ Write-Host " !" - NoNewline - ForegroundColor Gray
932
+ $script :nonewline = $true
933
+ $script :inerror = $false
934
+ }
935
+ else {
936
+ if ($script :nonewline ) {
937
+ Write-Host " `n " - NoNewline
938
+ }
939
+ if ($trimmedline.StartsWith (" [-]" ) -or $script :inerror ) {
940
+ Write-Host $line - ForegroundColor Red
941
+ $script :inerror = $true
942
+ }
943
+ elseif ($trimmedline.StartsWith (" VERBOSE:" )) {
944
+ Write-Host $line - ForegroundColor Yellow
945
+ $script :inerror = $false
946
+ }
947
+ elseif ($trimmedline.StartsWith (" Describing" ) -or $trimmedline.StartsWith (" Context" )) {
948
+ Write-Host $line - ForegroundColor Magenta
949
+ $script :inerror = $false
950
+ }
951
+ else {
952
+ Write-Host $line - ForegroundColor Gray
953
+ }
954
+ $script :nonewline = $false
955
+ }
956
+ }
957
+
910
958
# To ensure proper testing, the module path must not be inherited by the spawned process
911
959
try {
912
960
$originalModulePath = $env: PSModulePath
@@ -917,7 +965,17 @@ function Start-PSPester {
917
965
while ($true )
918
966
{
919
967
$lines = Get-Content $outputBufferFilePath | Select-Object - Skip $currentLines
920
- $lines | Write-Host
968
+ if ($Terse )
969
+ {
970
+ foreach ($line in $lines )
971
+ {
972
+ Write-Terse - line $line
973
+ }
974
+ }
975
+ else
976
+ {
977
+ $lines | Write-Host
978
+ }
921
979
if ($lines | Where-Object { $_ -eq ' __UNELEVATED_TESTS_THE_END__' })
922
980
{
923
981
break
@@ -942,7 +1000,14 @@ function Start-PSPester {
942
1000
try
943
1001
{
944
1002
$Command += " |Export-Clixml -Path '$passThruFile ' -Force"
945
- Start-NativeExecution - sb {& $powershell - noprofile - c $Command } | ForEach-Object { Write-Host $_ }
1003
+ if ($Terse )
1004
+ {
1005
+ Start-NativeExecution - sb {& $powershell - noprofile - c $Command } | ForEach-Object { Write-Terse $_ }
1006
+ }
1007
+ else
1008
+ {
1009
+ Start-NativeExecution - sb {& $powershell - noprofile - c $Command } | ForEach-Object { Write-Host $_ }
1010
+ }
946
1011
Import-Clixml - Path $passThruFile | Where-Object {$_.TotalCount -is [Int32 ]}
947
1012
}
948
1013
finally
@@ -952,7 +1017,14 @@ function Start-PSPester {
952
1017
}
953
1018
else
954
1019
{
955
- Start-NativeExecution - sb {& $powershell - noprofile - c $Command }
1020
+ if ($Terse )
1021
+ {
1022
+ Start-NativeExecution - sb {& $powershell - noprofile - c $Command } | ForEach-Object { Write-Terse - line $_ }
1023
+ }
1024
+ else
1025
+ {
1026
+ Start-NativeExecution - sb {& $powershell - noprofile - c $Command }
1027
+ }
956
1028
}
957
1029
}
958
1030
} finally {
0 commit comments