@@ -50,25 +50,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
50
50
private sealed trait TestSource { self =>
51
51
def name : String
52
52
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
63
54
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
72
56
73
57
def title : String = self match {
74
58
case self : JointCompilationSource =>
@@ -82,11 +66,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
82
66
/** Adds the flags specified in `newFlags0` if they do not already exist */
83
67
def withFlags (newFlags0 : String * ) = {
84
68
val newFlags = newFlags0.toArray
85
- if (! flags.containsSlice(newFlags)) self match {
69
+ if (! flags.options. containsSlice(newFlags)) self match {
86
70
case self : JointCompilationSource =>
87
- self.copy(flags = flags ++ newFlags)
71
+ self.copy(flags = flags.and( newFlags:_* ) )
88
72
case self : SeparateCompilationSource =>
89
- self.copy(flags = flags ++ newFlags)
73
+ self.copy(flags = flags.and( newFlags:_* ) )
90
74
}
91
75
else self
92
76
}
@@ -103,7 +87,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
103
87
|the test can be reproduced by running: """ .stripMargin
104
88
)
105
89
sb.append(" \n\n ./bin/dotc " )
106
- flags.foreach { arg =>
90
+ flags.all. foreach { arg =>
107
91
if (lineLen > maxLen) {
108
92
sb.append(" \\\n " )
109
93
lineLen = 4
@@ -147,7 +131,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
147
131
private final case class JointCompilationSource (
148
132
name : String ,
149
133
files : Array [JFile ],
150
- flags : Array [ String ] ,
134
+ flags : TestFlags ,
151
135
outDir : JFile
152
136
) extends TestSource {
153
137
def sourceFiles : Array [JFile ] = files.filter(isSourceFile)
@@ -161,7 +145,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
161
145
private final case class SeparateCompilationSource (
162
146
name : String ,
163
147
dir : JFile ,
164
- flags : Array [ String ] ,
148
+ flags : TestFlags ,
165
149
outDir : JFile
166
150
) extends TestSource {
167
151
@@ -342,9 +326,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
342
326
}
343
327
}
344
328
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 = {
346
330
347
- val flags = flags0 ++ Array (" -d" , targetDir.getAbsolutePath)
331
+ val flags = flags0 and (" -d" , targetDir.getAbsolutePath)
348
332
349
333
def flattenFiles (f : JFile ): Array [JFile ] =
350
334
if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -367,7 +351,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
367
351
" -encoding" , " UTF-8" ,
368
352
" -classpath" ,
369
353
s " .: ${Jars .scalaLibrary}: ${targetDir.getAbsolutePath}"
370
- ) ++ flags.takeRight(2 ) ++ fs
354
+ ) ++ flags.all. takeRight(2 ) ++ fs
371
355
372
356
val process = Runtime .getRuntime.exec(fullArgs)
373
357
val output = Source .fromInputStream(process.getErrorStream).mkString
@@ -395,7 +379,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
395
379
}
396
380
}
397
381
398
- val allArgs = addOutDir(flags)
382
+ val allArgs = addOutDir(flags.all )
399
383
400
384
// Compile with a try to catch any StackTrace generated by the compiler:
401
385
try {
@@ -1073,7 +1057,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1073
1057
}
1074
1058
1075
1059
/** 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 = {
1077
1061
val callingMethod = getCallingMethod()
1078
1062
val sourceFile = new JFile (f)
1079
1063
val parent = sourceFile.getParentFile
@@ -1103,7 +1087,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1103
1087
* By default, files are compiled in alphabetical order. An optional seed
1104
1088
* can be used for randomization.
1105
1089
*/
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 = {
1107
1091
val callingMethod = getCallingMethod()
1108
1092
val outDir = outDirectory + callingMethod + " /"
1109
1093
val sourceDir = new JFile (f)
@@ -1132,7 +1116,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1132
1116
* `testName` since files can be in separate directories and or be otherwise
1133
1117
* dissociated
1134
1118
*/
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 = {
1136
1120
val outDir = outDirectory + callingMethod + " /" + testName + " /"
1137
1121
1138
1122
// Directories in which to compile all containing files with `flags`:
@@ -1163,7 +1147,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1163
1147
* - Directories can have an associated check-file, where the check file has
1164
1148
* the same name as the directory (with the file extension `.check`)
1165
1149
*/
1166
- def compileFilesInDir (f : String , flags : Array [ String ] )(implicit outDirectory : String ): CompilationTest = {
1150
+ def compileFilesInDir (f : String , flags : TestFlags )(implicit outDirectory : String ): CompilationTest = {
1167
1151
val callingMethod = getCallingMethod()
1168
1152
val outDir = outDirectory + callingMethod + " /"
1169
1153
val sourceDir = new JFile (f)
@@ -1183,7 +1167,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1183
1167
* sub-directories and as such, does **not** perform separate compilation
1184
1168
* tests.
1185
1169
*/
1186
- def compileShallowFilesInDir (f : String , flags : Array [ String ] )(implicit outDirectory : String ): CompilationTest = {
1170
+ def compileShallowFilesInDir (f : String , flags : TestFlags )(implicit outDirectory : String ): CompilationTest = {
1187
1171
val callingMethod = getCallingMethod()
1188
1172
val outDir = outDirectory + callingMethod + " /"
1189
1173
val sourceDir = new JFile (f)
0 commit comments