@@ -70,6 +70,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
70
70
def outDir : JFile
71
71
def flags : TestFlags
72
72
def sourceFiles : Array [JFile ]
73
+ def checkFile : Option [JFile ]
73
74
74
75
def runClassPath : String = outDir.getPath + JFile .pathSeparator + flags.runClassPath
75
76
@@ -183,6 +184,10 @@ trait ParallelTesting extends RunnerOrchestration { self =>
183
184
decompilation : Boolean = false
184
185
) extends TestSource {
185
186
def sourceFiles : Array [JFile ] = files.filter(isSourceFile)
187
+
188
+ def checkFile : Option [JFile ] =
189
+ sourceFiles.map(f => new JFile (f.getPath.replaceFirst(" \\ .(scala|java)$" , " .check" )))
190
+ .find(_.exists())
186
191
}
187
192
188
193
/** A test source whose files will be compiled separately according to their
@@ -214,6 +219,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
214
219
.map { (g, f) => (g, f.sorted) }
215
220
216
221
def sourceFiles = compilationGroups.map(_._2).flatten.toArray
222
+
223
+ def checkFile : Option [JFile ] =
224
+ val platform =
225
+ if allToolArgs.getOrElse(ToolName .Target , Nil ).nonEmpty then s " . $testPlatform"
226
+ else " "
227
+ Some (new JFile (dir.getPath + platform + " .check" )).filter(_.exists)
217
228
}
218
229
219
230
protected def shouldSkipTestSource (testSource : TestSource ): Boolean = false
@@ -259,12 +270,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
259
270
final def countWarnings (reporters : Seq [TestReporter ]) = countErrorsAndWarnings(reporters)._2
260
271
final def reporterFailed (r : TestReporter ) = r.errorCount > 0
261
272
262
- /**
263
- * For a given test source, returns a check file against which the result of the test run
264
- * should be compared. Is used by implementations of this trait.
265
- */
266
- final def checkFile (testSource : TestSource ): Option [JFile ] = (CompilationLogic .checkFilePath(testSource)).filter(_.exists)
267
-
268
273
/**
269
274
* Checks if the given actual lines are the same as the ones in the check file.
270
275
* If not, fails the test.
@@ -340,22 +345,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
340
345
}
341
346
}
342
347
343
- object CompilationLogic {
344
- private [ParallelTesting ] def checkFilePath (testSource : TestSource ) = testSource match {
345
- case ts : JointCompilationSource =>
346
- ts.files.collectFirst {
347
- case f if ! f.isDirectory =>
348
- new JFile (f.getPath.replaceFirst(" \\ .(scala|java)$" , " .check" ))
349
- }
350
- case ts : SeparateCompilationSource =>
351
- val platform =
352
- if testSource.allToolArgs.getOrElse(ToolName .Target , Nil ).nonEmpty then
353
- s " . $testPlatform"
354
- else " "
355
- Option (new JFile (ts.dir.getPath + platform + " .check" ))
356
- }
357
- }
358
-
359
348
/** Each `Test` takes the `testSources` and performs the compilation and assertions
360
349
* according to the implementing class "neg", "run" or "pos".
361
350
*/
@@ -735,7 +724,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
735
724
private def mkReporter = TestReporter .reporter(realStdout, logLevel = mkLogLevel)
736
725
737
726
protected def diffCheckfile (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ) =
738
- checkFile( testSource) .foreach(diffTest(testSource, _, reporterOutputLines(reporters), reporters, logger))
727
+ testSource.checkFile .foreach(diffTest(testSource, _, reporterOutputLines(reporters), reporters, logger))
739
728
740
729
private def reporterOutputLines (reporters : Seq [TestReporter ]): List [String ] =
741
730
reporters.flatMap(_.consoleOutput.split(" \n " )).toList
@@ -938,7 +927,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
938
927
}
939
928
940
929
override def onSuccess (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ) =
941
- verifyOutput(checkFile( testSource) , testSource.outDir, testSource, countWarnings(reporters), reporters, logger)
930
+ verifyOutput(testSource.checkFile , testSource.outDir, testSource, countWarnings(reporters), reporters, logger)
942
931
}
943
932
944
933
private final class NegTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )(implicit summaryReport : SummaryReporting )
@@ -1177,7 +1166,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
1177
1166
def this (targets : List [TestSource ]) =
1178
1167
this (targets, 1 , true , None , false , false )
1179
1168
1180
- def checkFilePaths : List [JFile ] = targets.map( CompilationLogic .checkFilePath).flatten
1169
+ def checkFiles : List [JFile ] = targets.flatMap(_.checkFile)
1181
1170
1182
1171
def copy (targets : List [TestSource ],
1183
1172
times : Int = times,
0 commit comments