@@ -616,23 +616,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
616
616
else runMain(testSource.runClassPath) match {
617
617
case Success (_) if ! checkFile.isDefined || ! checkFile.get.exists => // success!
618
618
case Success (output) => {
619
- val outputLines = output.linesIterator.toArray :+ DiffUtil . EOF
620
- val checkLines : Array [String ] = Source .fromFile(checkFile.get, " UTF-8" ).getLines().toArray :+ DiffUtil . EOF
619
+ val outputLines = output.linesIterator.toSeq
620
+ val checkLines : Seq [String ] = Source .fromFile(checkFile.get, " UTF-8" ).getLines().toSeq
621
621
val sourceTitle = testSource.title
622
622
623
- def linesMatch =
624
- outputLines
625
- .zip(checkLines)
626
- .forall { case (x, y) => x == y }
623
+ diffMessage(sourceTitle, outputLines, checkLines).foreach { msg =>
627
624
628
- if (outputLines.length != checkLines.length || ! linesMatch) {
629
- // Print diff to files and summary:
630
- val diff = DiffUtil .mkColoredLineDiff(checkLines, outputLines)
631
-
632
- val msg =
633
- s """ |Output from ' $sourceTitle' did not match check file.
634
- |Diff (expected on the left, actual right):
635
- | """ .stripMargin + diff + " \n "
636
625
echo(msg)
637
626
addFailureInstruction(msg)
638
627
@@ -765,13 +754,34 @@ trait ParallelTesting extends RunnerOrchestration { self =>
765
754
}
766
755
}
767
756
757
+ def fail (msg : String ): Unit = {
758
+ echo(msg)
759
+ failTestSource(testSource)
760
+ }
761
+
762
+ def reporterOutputLines (reporters : List [TestReporter ]): List [String ] = {
763
+ reporters.flatMap(_.allErrors).sortBy(_.pos.source.toString).flatMap { error =>
764
+ (error.pos.span.toString + " in " + error.pos.source.file.name) :: error.getMessage().lines.toList
765
+ }
766
+ }
767
+ def checkFileTest (sourceName : String , checkFile : JFile , actual : List [String ]) = {
768
+ val expexted = Source .fromFile(checkFile, " UTF-8" ).getLines().toList
769
+ diffMessage(sourceName, actual, expexted).foreach(fail)
770
+ }
771
+
768
772
val (compilerCrashed, expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match {
769
773
case testSource @ JointCompilationSource (_, files, flags, outDir, fromTasty, decompilation) =>
770
774
val sourceFiles = testSource.sourceFiles
771
775
val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(sourceFiles)
772
776
val reporter = compile(sourceFiles, flags, true , outDir)
773
777
val actualErrors = reporter.errorCount
774
-
778
+ files.foreach { file =>
779
+ if (! file.isDirectory) {
780
+ val checkFile = new JFile (file.getAbsolutePath.replaceFirst(" \\ .scala$" , " .check" ))
781
+ if (checkFile.exists)
782
+ checkFileTest(testSource.title, checkFile, reporterOutputLines(reporter :: Nil ))
783
+ }
784
+ }
775
785
if (reporter.compilerCrashed || actualErrors > 0 )
776
786
logReporterContents(reporter)
777
787
@@ -788,14 +798,14 @@ trait ParallelTesting extends RunnerOrchestration { self =>
788
798
if (actualErrors > 0 )
789
799
reporters.foreach(logReporterContents)
790
800
801
+ val checkFile = new JFile (dir.getAbsolutePath + " .check" )
802
+ if (checkFile.exists)
803
+ checkFileTest(testSource.title, checkFile, reporterOutputLines(reporters))
804
+
791
805
(compilerCrashed, expectedErrors, actualErrors, () => getMissingExpectedErrors(errorMap, errors), errorMap)
792
806
}
793
807
}
794
808
795
- def fail (msg : String ): Unit = {
796
- echo(msg)
797
- failTestSource(testSource)
798
- }
799
809
800
810
if (compilerCrashed)
801
811
fail(s " Compiler crashed when compiling: ${testSource.title}" )
@@ -839,6 +849,22 @@ trait ParallelTesting extends RunnerOrchestration { self =>
839
849
}
840
850
}
841
851
852
+ def diffMessage (sourceTitle : String , outputLines : Seq [String ], checkLines : Seq [String ]): Option [String ] = {
853
+ def linesMatch =
854
+ (outputLines, checkLines).zipped.forall(_ == _)
855
+
856
+ if (outputLines.length != checkLines.length || ! linesMatch) {
857
+ // Print diff to files and summary:
858
+ val diff = DiffUtil .mkColoredLineDiff(checkLines :+ DiffUtil .EOF , outputLines :+ DiffUtil .EOF )
859
+
860
+ Some (
861
+ s """ |Output from ' $sourceTitle' did not match check file.
862
+ |Diff (expected on the left, actual right):
863
+ | """ .stripMargin + diff + " \n " )
864
+ } else None
865
+
866
+ }
867
+
842
868
/** The `CompilationTest` is the main interface to `ParallelTesting`, it
843
869
* can be instantiated via one of the following methods:
844
870
*
0 commit comments