@@ -111,6 +111,25 @@ function GenerateRunSettings([String] $framework, [String] $platform, [String] $
111111 return $fileName
112112}
113113
114+ function RunTestTasksInForeground ($tasks ) {
115+ $failedTests = @ ()
116+ foreach ($task in $tasks ) {
117+ & dotnet test $task.params
118+ Write-Host
119+ if ($LastExitCode -ne 0 ) {
120+ $global :Result = $LastExitCode
121+ Write-Host - ForegroundColor Red " $ ( $task.name ) failed"
122+ $failedTests += $task.name
123+ } else {
124+ Write-Host " $ ( $task.name ) succeeded"
125+ }
126+ if ($failedTests ) {
127+ Write-Host - ForegroundColor Red " $ ( $failedTests.Count ) test task(s) failed: $ ( $failedTests -Join " , " ) "
128+ }
129+ Write-Host
130+ }
131+ }
132+
114133function RunTestTasks ($tasks ) {
115134 $maxJobs = $jobs
116135 if ($tasks.Count -lt $maxJobs ) {
@@ -148,7 +167,7 @@ function RunTestTasks($tasks) {
148167 $testName = $tasks [$bgJobs .$finished ].name
149168 Write-Host
150169 if ($finished.State -eq ' Failed' ) {
151- Write-Host " $testName failed"
170+ Write-Host - ForegroundColor Red " $testName failed"
152171 $global :Result = $finished.ChildJobs [0 ].JobStateInfo.Reason.ErrorRecord.TargetObject
153172 $failedTests += $testName
154173 } else {
@@ -165,7 +184,7 @@ function RunTestTasks($tasks) {
165184 Write-Host " $ ( $bgJobs.Count ) jobs running: $ ( ($bgJobs.values | ForEach-Object {$tasks [$_ ].name}) -Join " , " ) "
166185 Write-Host " $ ( $tasks.Count - $nextJob ) jobs pending: $ ( ($nextJob .. $tasks.Count | ForEach-Object {$tasks [$_ ].name}) -Join " , " ) "
167186 if ($failedTests ) {
168- Write-Host " $ ( $failedTests.Count ) jobs failed: $ ( $failedTests -Join " , " ) "
187+ Write-Host - ForegroundColor Red " $ ( $failedTests.Count ) jobs failed: $ ( $failedTests -Join " , " ) "
169188 }
170189 Write-Host
171190 }
@@ -211,7 +230,11 @@ function Test([String] $target, [String] $configuration, [String[]] $frameworks,
211230 }
212231 }
213232
214- RunTestTasks $tasks
233+ if ($jobs -eq 0 ) {
234+ RunTestTasksInForeground $tasks
235+ } else {
236+ RunTestTasks $tasks
237+ }
215238}
216239
217240function Purge () {
0 commit comments