@@ -56,6 +56,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
56
56
def name : String
57
57
def outDir : JFile
58
58
def flags : TestFlags
59
+ def sourceFiles : Array [JFile ]
59
60
60
61
def runClassPath : String = outDir.getAbsolutePath + JFile .pathSeparator + flags.runClassPath
61
62
@@ -141,7 +142,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
141
142
fromTasty : Boolean = false ,
142
143
decompilation : Boolean = false
143
144
) extends TestSource {
144
- def sourceFiles : Array [JFile ] = files.filter(isSourceFile)
145
+ def sourceFiles : Array [JFile ] = files.filter(isSourceFile).toArray
145
146
146
147
override def toString () = outDir.toString
147
148
}
@@ -178,6 +179,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
178
179
.getOrElse(" " )
179
180
}
180
181
.toList.sortBy(_._1).map(_._2.filter(isSourceFile).sorted)
182
+
183
+ def sourceFiles : Array [JFile ] = compilationGroups.flatten.filter(isSourceFile).toArray
181
184
}
182
185
183
186
private trait CompilationLogic { this : Test =>
@@ -205,29 +208,30 @@ trait ParallelTesting extends RunnerOrchestration { self =>
205
208
ts.files.filter(f => ! f.isDirectory).map { f => new JFile (f.getAbsolutePath.replaceFirst(" \\ .scala$" , " .check" )) }.headOption
206
209
207
210
case ts : SeparateCompilationSource =>
208
- Option (new JFile (dir.getAbsolutePath + " .check" ))
211
+ Option (new JFile (ts. dir.getAbsolutePath + " .check" ))
209
212
}).filter(_.exists)
210
213
211
- final def diffTest (sourceName : String , checkFile : JFile , actual : List [String ]) = {
214
+ final def diffTest (testSource : TestSource , checkFile : JFile , actual : List [String ]) = {
212
215
val expected = Source .fromFile(checkFile, " UTF-8" ).getLines().toList
213
- for (msg <- diffMessage(sourceName, actual, expected)) {
214
- fail(msg)
216
+ for (msg <- diffMessage(testSource.title, actual, expected)) {
217
+ echo(msg)
218
+ failTestSource(testSource)
215
219
dumpOutputToFile(checkFile, actual)
216
220
}
217
221
}
218
222
219
- final def encapsulatedCompilation (testSource : TestSource ) = new LoggedRunnable { self =>
223
+ def encapsulatedCompilation (testSource : TestSource ) = new LoggedRunnable { self =>
220
224
def checkTestSource (): Unit = tryCompile(testSource) {
221
225
val reporters = compileTestSource(testSource)
222
226
onComplete(testSource, reporters, self)
223
227
registerCompletion()
224
228
}
225
229
}
226
230
227
- final def onComplete (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ): Unit =
228
- testFailed(testSource, reporters).fold(
229
- onSuccess(testSource, reporters, logger )
230
- , msg => onFailure(testSource, reporters, logger, Option (msg).filter(_.nonEmpty)) )
231
+ final def onComplete (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ): Unit = (
232
+ testFailed(testSource, reporters).fold
233
+ ( onSuccess(testSource, reporters, logger ) )
234
+ ( msg => onFailure(testSource, reporters, logger, Option (msg).filter(_.nonEmpty)) ) )
231
235
232
236
def testFailed (testSource : TestSource , reporters : Seq [TestReporter ]): Option [String ] =
233
237
Option (reporters.exists(reporterFailed)).map(_ => s " Compilation failed for: ' ${testSource.title}' " )
@@ -621,8 +625,8 @@ trait ParallelTesting extends RunnerOrchestration { self =>
621
625
private [this ] def verifyOutput (checkFile : Option [JFile ], dir : JFile , testSource : TestSource , warnings : Int ) = {
622
626
if (Properties .testsNoRun) addNoRunWarning()
623
627
else runMain(testSource.runClassPath) match {
624
- case Success (_) if ! checkFile.isDefined || ! checkFile.get.exists => // success!
625
- case Success (output) => checkFile.foreach(diffTest(testSource, _, output.linesIterator.toSeq ))
628
+ case Success (_) if ! checkFile.isDefined || ! checkFile.get.exists =>
629
+ case Success (output) => checkFile.foreach(diffTest(testSource, _, output.linesIterator.toList ))
626
630
case Failure (output) =>
627
631
echo(s " Test ' ${testSource.title}' failed with output: " )
628
632
echo(output)
@@ -639,33 +643,34 @@ trait ParallelTesting extends RunnerOrchestration { self =>
639
643
640
644
private final class NegTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )(implicit summaryReport : SummaryReporting )
641
645
extends Test (testSources, times, threadLimit, suppressAllOutput) {
642
- override def testFailed (reporters : Seq [TestReporter ]): Option [() => Unit ] = {
646
+ override def testFailed (testSource : TestSource , reporters : Seq [TestReporter ]): Option [String ] = {
643
647
val compilerCrashed = reporters.exists(_.compilerCrashed)
644
648
val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(testSource.sourceFiles)
645
649
val actualErrors = reporters.foldLeft(0 )(_ + _.errorCount)
650
+ val hasMissingAnnotations = getMissingExpectedErrors(errorMap, reporters.iterator.flatMap(_.errors))
646
651
647
652
if (compilerCrashed ) Some (s " Compiler crashed when compiling: ${testSource.title}" )
648
653
else if (actualErrors == 0 ) Some (s " \n No errors found when compiling neg test $testSource" )
649
654
else if (expectedErrors != actualErrors) Some (s " \n Wrong number of errors encountered when compiling $testSource, expected: $expectedErrors, actual: $actualErrors" )
650
- else if (hasMissingAnnotations() ) Some (s " \n Errors found on incorrect row numbers when compiling $testSource" )
655
+ else if (hasMissingAnnotations ) Some (s " \n Errors found on incorrect row numbers when compiling $testSource" )
651
656
else if (! errorMap.isEmpty ) Some (s " \n Expected error(s) have {<error position>=<unreported error>}: $errorMap" )
652
657
else None
653
658
}
654
659
655
660
override def onSuccess (testSource : TestSource , reporters : Seq [TestReporter ], logger : LoggedRunnable ): Unit =
656
- checkFile(testSource).foreach(diffTest(testSource.title , _, reporterOutputLines(reporters)))
661
+ checkFile(testSource).foreach(diffTest(testSource, _, reporterOutputLines(reporters)))
657
662
658
- def reporterOutputLines (reporters : List [TestReporter ]): List [String ] =
663
+ def reporterOutputLines (reporters : Seq [TestReporter ]): List [String ] =
659
664
reporters.flatMap(_.allErrors).sortBy(_.pos.source.toString).flatMap { error =>
660
- (error.pos.span.toString + " in " + error.pos.source.file.name) :: error.getMessage().linesIterator.toList }
665
+ (error.pos.span.toString + " in " + error.pos.source.file.name) :: error.getMessage().linesIterator.toList }.toList
661
666
662
667
// In neg-tests we allow two types of error annotations,
663
668
// "nopos-error" which doesn't care about position and "error" which
664
669
// has to be annotated on the correct line number.
665
670
//
666
671
// We collect these in a map `"file:row" -> numberOfErrors`, for
667
672
// nopos errors we save them in `"file" -> numberOfNoPosErrors`
668
- def getErrorMapAndExpectedCount (files : Array [JFile ]): (HashMap [String , Integer ], Int ) = {
673
+ def getErrorMapAndExpectedCount (files : Seq [JFile ]): (HashMap [String , Integer ], Int ) = {
669
674
val errorMap = new HashMap [String , Integer ]()
670
675
var expectedErrors = 0
671
676
files.filter(_.getName.endsWith(" .scala" )).foreach { file =>
@@ -711,7 +716,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
711
716
712
717
private final class NoCrashTest (testSources : List [TestSource ], times : Int , threadLimit : Option [Int ], suppressAllOutput : Boolean )(implicit summaryReport : SummaryReporting )
713
718
extends Test (testSources, times, threadLimit, suppressAllOutput) {
714
- override protected def encapsulatedCompilation (testSource : TestSource ) = new LoggedRunnable {
719
+ override def encapsulatedCompilation (testSource : TestSource ) = new LoggedRunnable {
715
720
def checkTestSource (): Unit = tryCompile(testSource) {
716
721
def fail (msg : String ): Nothing = {
717
722
echo(msg)
0 commit comments