@@ -15,6 +15,7 @@ import java.nio.file.{ Files, Path, Paths, NoSuchFileException }
15
15
import java .util .concurrent .{ Executors => JExecutors , TimeUnit }
16
16
import scala .util .control .NonFatal
17
17
import scala .util .Try
18
+ import scala .collection .mutable
18
19
import java .util .HashMap
19
20
20
21
trait ParallelTesting {
@@ -539,13 +540,31 @@ trait ParallelTesting {
539
540
else (dirs, f :: files)
540
541
}
541
542
543
+ private def getCallingMethod (): String = {
544
+ val seen = mutable.Set .empty[String ]
545
+ Thread .currentThread.getStackTrace
546
+ .filter { elem =>
547
+ if (seen.contains(elem.getMethodName)) false
548
+ else { seen += elem.getMethodName; true }
549
+ }
550
+ .take(6 ).find { elem =>
551
+ val callingClass = Class .forName(elem.getClassName)
552
+ classOf [ParallelTesting ].isAssignableFrom(callingClass) &&
553
+ elem.getFileName != " ParallelTesting.scala"
554
+ }
555
+ .map(_.getMethodName)
556
+ .getOrElse {
557
+ throw new IllegalStateException (" Unable to reflectively find calling method" )
558
+ }
559
+ }
560
+
542
561
def compileFile (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
543
- // each calling method gets its own unique output directory, in which we
544
- // place the dir being compiled:
545
- val callingMethod = Thread .currentThread.getStackTrace.apply(3 ).getMethodName
546
- val outDir = outDirectory + callingMethod + " /"
547
562
val sourceFile = new JFile (f)
548
563
val parent = sourceFile.getParentFile
564
+ val outDir =
565
+ outDirectory + getCallingMethod + " /" +
566
+ sourceFile.getName.substring(0 , sourceFile.getName.lastIndexOf('.' )) + " /"
567
+
549
568
require(
550
569
sourceFile.exists && ! sourceFile.isDirectory &&
551
570
(parent ne null ) && parent.exists && parent.isDirectory,
@@ -561,10 +580,7 @@ trait ParallelTesting {
561
580
}
562
581
563
582
def compileDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
564
- // each calling method gets its own unique output directory, in which we
565
- // place the dir being compiled:
566
- val callingMethod = Thread .currentThread.getStackTrace.apply(3 ).getMethodName
567
- val outDir = outDirectory + callingMethod + " /"
583
+ val outDir = outDirectory + getCallingMethod + " /"
568
584
val sourceDir = new JFile (f)
569
585
requirements(f, sourceDir, outDir)
570
586
@@ -573,18 +589,15 @@ trait ParallelTesting {
573
589
else Array (f)
574
590
575
591
// Directories in which to compile all containing files with `flags`:
576
- val targetDir = new JFile (outDir)
592
+ val targetDir = new JFile (outDir + " / " + sourceDir.getName + " / " )
577
593
targetDir.mkdirs()
578
594
579
595
val target = ConcurrentCompilationTarget (flatten(sourceDir), flags, targetDir)
580
596
new CompilationTest (target)
581
597
}
582
598
583
599
def compileList (files : List [String ], flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
584
- // each calling method gets its own unique output directory, in which we
585
- // place the dir being compiled:
586
- val callingMethod = Thread .currentThread.getStackTrace.apply(3 ).getMethodName
587
- val outDir = outDirectory + callingMethod + " /"
600
+ val outDir = outDirectory + getCallingMethod + " /" + testName + " /"
588
601
589
602
// Directories in which to compile all containing files with `flags`:
590
603
val targetDir = new JFile (outDir)
@@ -598,10 +611,7 @@ trait ParallelTesting {
598
611
}
599
612
600
613
def compileFilesInDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
601
- // each calling method gets its own unique output directory, in which we
602
- // place the dir being compiled:
603
- val callingMethod = Thread .currentThread.getStackTrace.apply(3 ).getMethodName
604
- val outDir = outDirectory + callingMethod + " /"
614
+ val outDir = outDirectory + getCallingMethod + " /"
605
615
val sourceDir = new JFile (f)
606
616
requirements(f, sourceDir, outDir)
607
617
@@ -616,10 +626,7 @@ trait ParallelTesting {
616
626
}
617
627
618
628
def compileShallowFilesInDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
619
- // each calling method gets its own unique output directory, in which we
620
- // place the dir being compiled:
621
- val callingMethod = Thread .currentThread.getStackTrace.apply(3 ).getMethodName
622
- val outDir = outDirectory + callingMethod + " /"
629
+ val outDir = outDirectory + getCallingMethod + " /"
623
630
val sourceDir = new JFile (f)
624
631
requirements(f, sourceDir, outDir)
625
632
0 commit comments