@@ -50,25 +50,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
5050 private sealed trait TestSource { self =>
5151 def name : String
5252 def outDir : JFile
53- def flags : Array [String ]
54-
55- def classPath : String =
56- outDir.getAbsolutePath +
57- flags
58- .dropWhile(_ != " -classpath" )
59- .drop(1 )
60- .headOption
61- .map(" :" + _)
62- .getOrElse(" " )
53+ def flags : TestFlags
6354
64- def runClassPath = {
65- flags
66- .dropWhile(_ != " -YRunClasspath" )
67- .drop(1 )
68- .headOption
69- .map(outDir.getAbsolutePath + " :" + _)
70- .getOrElse(classPath)
71- }
55+ def runClassPath : String = outDir.getAbsolutePath + " :" + flags.runClassPath
7256
7357 def title : String = self match {
7458 case self : JointCompilationSource =>
@@ -82,11 +66,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
8266 /** Adds the flags specified in `newFlags0` if they do not already exist */
8367 def withFlags (newFlags0 : String * ) = {
8468 val newFlags = newFlags0.toArray
85- if (! flags.containsSlice(newFlags)) self match {
69+ if (! flags.options. containsSlice(newFlags)) self match {
8670 case self : JointCompilationSource =>
87- self.copy(flags = flags ++ newFlags)
71+ self.copy(flags = flags.and( newFlags:_* ) )
8872 case self : SeparateCompilationSource =>
89- self.copy(flags = flags ++ newFlags)
73+ self.copy(flags = flags.and( newFlags:_* ) )
9074 }
9175 else self
9276 }
@@ -103,7 +87,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10387 |the test can be reproduced by running: """ .stripMargin
10488 )
10589 sb.append(" \n\n ./bin/dotc " )
106- flags.foreach { arg =>
90+ flags.all. foreach { arg =>
10791 if (lineLen > maxLen) {
10892 sb.append(" \\\n " )
10993 lineLen = 4
@@ -147,7 +131,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
147131 private final case class JointCompilationSource (
148132 name : String ,
149133 files : Array [JFile ],
150- flags : Array [ String ] ,
134+ flags : TestFlags ,
151135 outDir : JFile
152136 ) extends TestSource {
153137 def sourceFiles : Array [JFile ] = files.filter(isSourceFile)
@@ -161,7 +145,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
161145 private final case class SeparateCompilationSource (
162146 name : String ,
163147 dir : JFile ,
164- flags : Array [ String ] ,
148+ flags : TestFlags ,
165149 outDir : JFile
166150 ) extends TestSource {
167151
@@ -342,9 +326,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
342326 }
343327 }
344328
345- protected def compile (files0 : Array [JFile ], flags0 : Array [ String ] , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
329+ protected def compile (files0 : Array [JFile ], flags0 : TestFlags , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
346330
347- val flags = flags0 ++ Array (" -d" , targetDir.getAbsolutePath)
331+ val flags = flags0 and (" -d" , targetDir.getAbsolutePath)
348332
349333 def flattenFiles (f : JFile ): Array [JFile ] =
350334 if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -367,7 +351,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
367351 " -encoding" , " UTF-8" ,
368352 " -classpath" ,
369353 s " .: ${Jars .scalaLibrary}: ${targetDir.getAbsolutePath}"
370- ) ++ flags.takeRight(2 ) ++ fs
354+ ) ++ flags.all. takeRight(2 ) ++ fs
371355
372356 val process = Runtime .getRuntime.exec(fullArgs)
373357 val output = Source .fromInputStream(process.getErrorStream).mkString
@@ -395,7 +379,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
395379 }
396380 }
397381
398- val allArgs = addOutDir(flags)
382+ val allArgs = addOutDir(flags.all )
399383
400384 // Compile with a try to catch any StackTrace generated by the compiler:
401385 try {
@@ -1073,7 +1057,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
10731057 }
10741058
10751059 /** Compiles a single file from the string path `f` using the supplied flags */
1076- def compileFile (f : String , flags : Array [ String ] )(implicit outDirectory : String ): CompilationTest = {
1060+ def compileFile (f : String , flags : TestFlags )(implicit outDirectory : String ): CompilationTest = {
10771061 val callingMethod = getCallingMethod()
10781062 val sourceFile = new JFile (f)
10791063 val parent = sourceFile.getParentFile
@@ -1103,7 +1087,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11031087 * By default, files are compiled in alphabetical order. An optional seed
11041088 * can be used for randomization.
11051089 */
1106- def compileDir (f : String , flags : Array [ String ] , randomOrder : Option [Int ] = None )(implicit outDirectory : String ): CompilationTest = {
1090+ def compileDir (f : String , flags : TestFlags , randomOrder : Option [Int ] = None )(implicit outDirectory : String ): CompilationTest = {
11071091 val callingMethod = getCallingMethod()
11081092 val outDir = outDirectory + callingMethod + " /"
11091093 val sourceDir = new JFile (f)
@@ -1132,7 +1116,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11321116 * `testName` since files can be in separate directories and or be otherwise
11331117 * dissociated
11341118 */
1135- def compileList (testName : String , files : List [String ], flags : Array [ String ] , callingMethod : String = getCallingMethod())(implicit outDirectory : String ): CompilationTest = {
1119+ def compileList (testName : String , files : List [String ], flags : TestFlags , callingMethod : String = getCallingMethod())(implicit outDirectory : String ): CompilationTest = {
11361120 val outDir = outDirectory + callingMethod + " /" + testName + " /"
11371121
11381122 // Directories in which to compile all containing files with `flags`:
@@ -1163,7 +1147,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11631147 * - Directories can have an associated check-file, where the check file has
11641148 * the same name as the directory (with the file extension `.check`)
11651149 */
1166- def compileFilesInDir (f : String , flags : Array [ String ] )(implicit outDirectory : String ): CompilationTest = {
1150+ def compileFilesInDir (f : String , flags : TestFlags )(implicit outDirectory : String ): CompilationTest = {
11671151 val callingMethod = getCallingMethod()
11681152 val outDir = outDirectory + callingMethod + " /"
11691153 val sourceDir = new JFile (f)
@@ -1183,7 +1167,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
11831167 * sub-directories and as such, does **not** perform separate compilation
11841168 * tests.
11851169 */
1186- def compileShallowFilesInDir (f : String , flags : Array [ String ] )(implicit outDirectory : String ): CompilationTest = {
1170+ def compileShallowFilesInDir (f : String , flags : TestFlags )(implicit outDirectory : String ): CompilationTest = {
11871171 val callingMethod = getCallingMethod()
11881172 val outDir = outDirectory + callingMethod + " /"
11891173 val sourceDir = new JFile (f)
0 commit comments