@@ -12,7 +12,7 @@ import java.nio.file.{Files, NoSuchFileException, Path, Paths}
12
12
import java .nio .charset .{Charset , StandardCharsets }
13
13
import java .text .SimpleDateFormat
14
14
import java .util .{HashMap , Timer , TimerTask }
15
- import java .util .concurrent .{TimeUnit , TimeoutException , Executors => JExecutors }
15
+ import java .util .concurrent .{ExecutionException , TimeUnit , TimeoutException , Executors => JExecutors }
16
16
17
17
import scala .collection .mutable
18
18
import scala .io .{Codec , Source }
@@ -494,6 +494,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
494
494
.and(" -d" , targetDir.getPath)
495
495
.withClasspath(targetDir.getPath)
496
496
497
+ def waitForJudiciously (process : Process ): Int =
498
+ try process.waitFor()
499
+ catch case _ : InterruptedException =>
500
+ try if process.waitFor(5L , TimeUnit .MINUTES ) then process.exitValue() else - 2
501
+ finally Thread .currentThread.interrupt()
502
+
497
503
def compileWithJavac (fs : Array [String ]) = if (fs.nonEmpty) {
498
504
val fullArgs = Array (
499
505
" javac" ,
@@ -503,7 +509,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
503
509
val process = Runtime .getRuntime.exec(fullArgs)
504
510
val output = Source .fromInputStream(process.getErrorStream).mkString
505
511
506
- if (process.waitFor( ) != 0 ) Some (output)
512
+ if waitForJudiciously (process) != 0 then Some (output)
507
513
else None
508
514
} else None
509
515
@@ -676,7 +682,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
676
682
677
683
for fut <- eventualResults do
678
684
try fut.get()
679
- catch case ex : Exception =>
685
+ catch
686
+ case ee : ExecutionException if ee.getCause.isInstanceOf [InterruptedException ] =>
687
+ System .err.println(" Interrupted (probably running after shutdown)" )
688
+ ee.printStackTrace()
689
+ case ex : Exception =>
680
690
System .err.println(ex.getMessage)
681
691
ex.printStackTrace()
682
692
0 commit comments