@@ -8,6 +8,7 @@ import java.util.HashMap
8
8
import java .nio .file .StandardCopyOption .REPLACE_EXISTING
9
9
import java .nio .file .{Files , NoSuchFileException , Path , Paths }
10
10
import java .util .concurrent .{TimeUnit , TimeoutException , Executors => JExecutors }
11
+ import java .util .{Timer , TimerTask }
11
12
12
13
import scala .io .Source
13
14
import scala .util .control .NonFatal
@@ -285,11 +286,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
285
286
realStderr.println(msg + paddingRight)
286
287
}
287
288
288
- /** A single `Runnable` that prints a progress bar for the curent `Test` */
289
- private def createProgressMonitor : Runnable = () => {
289
+ /** Print a progress bar for the curent `Test` */
290
+ private def updateProgressMonitor () : Unit = {
290
291
val start = System .currentTimeMillis
291
292
var tCompiled = testSourcesCompleted
292
- while (tCompiled < sourceCount) {
293
+ if (tCompiled < sourceCount) {
293
294
val timestamp = (System .currentTimeMillis - start) / 1000
294
295
val progress = (tCompiled.toDouble / sourceCount * 40 ).toInt
295
296
@@ -299,16 +300,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
299
300
(" " * (39 - progress)) +
300
301
s " ] completed ( $tCompiled/ $sourceCount, $failureCount failed, ${timestamp}s) \r "
301
302
)
302
-
303
- Thread .sleep(100 )
304
- tCompiled = testSourcesCompleted
305
303
}
306
-
307
- val timestamp = (System .currentTimeMillis - start) / 1000
308
- // println, otherwise no newline and cursor at start of line
309
- realStdout.println(
310
- s " [=======================================] completed ( $sourceCount/ $sourceCount, $failureCount failed, ${timestamp}s) "
311
- )
304
+ else {
305
+ val timestamp = (System .currentTimeMillis - start) / 1000
306
+ // println, otherwise no newline and cursor at start of line
307
+ realStdout.print(
308
+ s " [=======================================] completed ( $sourceCount/ $sourceCount, $failureCount failed, ${timestamp}s) \r "
309
+ )
310
+ }
312
311
}
313
312
314
313
/** Wrapper function to make sure that the compiler itself did not crash -
@@ -465,7 +464,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
465
464
case None => JExecutors .newWorkStealingPool()
466
465
}
467
466
468
- if (isInteractive && ! suppressAllOutput) pool.submit(createProgressMonitor)
467
+ val timer = new Timer ()
468
+ val logProgress = isInteractive && ! suppressAllOutput
469
+ if (logProgress) {
470
+ val task = new TimerTask {
471
+ def run () = updateProgressMonitor()
472
+ }
473
+ timer.schedule(task, 100 , 200 )
474
+ }
469
475
470
476
val eventualResults = filteredSources.map { target =>
471
477
pool.submit(encapsulatedCompilation(target))
@@ -481,6 +487,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
481
487
482
488
eventualResults.foreach(_.get)
483
489
490
+ if (logProgress) {
491
+ timer.cancel()
492
+ // update progress one last time
493
+ updateProgressMonitor()
494
+ }
495
+
484
496
if (didFail) {
485
497
reportFailed()
486
498
failedTestSources.toSet.foreach(addFailedTest)
0 commit comments