@@ -24,13 +24,16 @@ trait ParallelTesting {
24
24
def outDir : JFile
25
25
def flags : Array [String ]
26
26
27
- def withFlags (newFlags : Array [String ]) = self match {
28
- case self : ConcurrentCompilationTarget =>
29
- self.copy(flags = newFlags)
30
- case self : SeparateCompilationTarget =>
31
- self.copy(flags = newFlags)
32
- }
27
+ def withFlags (newFlags : Array [String ]) =
28
+ if (! flags.containsSlice(newFlags)) self match {
29
+ case self : ConcurrentCompilationTarget =>
30
+ self.copy(flags = newFlags)
31
+ case self : SeparateCompilationTarget =>
32
+ self.copy(flags = newFlags)
33
+ }
34
+ else self
33
35
}
36
+
34
37
private final case class ConcurrentCompilationTarget (
35
38
files : Array [JFile ],
36
39
flags : Array [String ],
@@ -387,8 +390,12 @@ trait ParallelTesting {
387
390
}
388
391
389
392
def addOutDir (xs : Array [String ]): Array [String ] = {
390
- val (beforeCp, cp :: cpArg :: rest) = xs.toList.span(_ != " -classpath" )
391
- (beforeCp ++ (cp :: (cpArg + s " : ${targetDir.getAbsolutePath}" ) :: rest)).toArray
393
+ val (beforeCp, cpAndAfter) = xs.toList.span(_ != " -classpath" )
394
+ if (cpAndAfter.nonEmpty) {
395
+ val (cp :: cpArg :: rest) = cpAndAfter
396
+ (beforeCp ++ (cp :: (cpArg + s " : ${targetDir.getAbsolutePath}" ) :: rest)).toArray
397
+ }
398
+ else (beforeCp ++ (" -classpath" :: targetDir.getAbsolutePath :: Nil )).toArray
392
399
}
393
400
394
401
def compileWithJavac (fs : Array [String ]) = if (fs.nonEmpty) {
@@ -538,7 +545,7 @@ trait ParallelTesting {
538
545
targetDir
539
546
}
540
547
541
- private def requirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
548
+ private def checkRequirements (f : String , sourceDir : JFile , outDir : String ): Unit = {
542
549
require(sourceDir.isDirectory && sourceDir.exists, " passed non-directory to `compileFilesInDir`" )
543
550
require(outDir.last == '/' , " please specify an `outDir` with a trailing slash" )
544
551
}
@@ -593,7 +600,7 @@ trait ParallelTesting {
593
600
def compileDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
594
601
val outDir = outDirectory + getCallingMethod + " /"
595
602
val sourceDir = new JFile (f)
596
- requirements (f, sourceDir, outDir)
603
+ checkRequirements (f, sourceDir, outDir)
597
604
598
605
def flatten (f : JFile ): Array [JFile ] =
599
606
if (f.isDirectory) f.listFiles.flatMap(flatten)
@@ -624,7 +631,7 @@ trait ParallelTesting {
624
631
def compileFilesInDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
625
632
val outDir = outDirectory + getCallingMethod + " /"
626
633
val sourceDir = new JFile (f)
627
- requirements (f, sourceDir, outDir)
634
+ checkRequirements (f, sourceDir, outDir)
628
635
629
636
val (dirs, files) = compilationTargets(sourceDir)
630
637
@@ -639,7 +646,7 @@ trait ParallelTesting {
639
646
def compileShallowFilesInDir (f : String , flags : Array [String ])(implicit outDirectory : String ): CompilationTest = {
640
647
val outDir = outDirectory + getCallingMethod + " /"
641
648
val sourceDir = new JFile (f)
642
- requirements (f, sourceDir, outDir)
649
+ checkRequirements (f, sourceDir, outDir)
643
650
644
651
val (_, files) = compilationTargets(sourceDir)
645
652
0 commit comments