@@ -616,23 +616,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
616616 else runMain(testSource.runClassPath) match {
617617 case Success (_) if ! checkFile.isDefined || ! checkFile.get.exists => // success!
618618 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
621621 val sourceTitle = testSource.title
622622
623- def linesMatch =
624- outputLines
625- .zip(checkLines)
626- .forall { case (x, y) => x == y }
623+ diffMessage(sourceTitle, outputLines, checkLines).foreach { msg =>
627624
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 "
636625 echo(msg)
637626 addFailureInstruction(msg)
638627
@@ -765,13 +754,36 @@ trait ParallelTesting extends RunnerOrchestration { self =>
765754 }
766755 }
767756
757+ def fail (msg : String ): Unit = {
758+ echo(msg)
759+ failTestSource(testSource)
760+ }
761+
762+ def reporterOutputLines (reporter : TestReporter ): List [String ] = {
763+ reporter.allErrors.flatMap { error =>
764+ (error.pos.span.toString + " in " + error.pos.source.file.name) :: error.getMessage().split(" \n " ).toList
765+ }
766+ }
767+ def checkFileTest (sourceName : String , checkFile : JFile , actual : List [String ]) = {
768+ if (checkFile.exists) {
769+ val expexted = Source .fromFile(checkFile, " UTF-8" ).getLines().toList
770+ diffMessage(sourceName, actual, expexted).foreach(fail)
771+ }
772+ }
773+
768774 val (compilerCrashed, expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match {
769775 case testSource @ JointCompilationSource (_, files, flags, outDir, fromTasty, decompilation) =>
770776 val sourceFiles = testSource.sourceFiles
771777 val (errorMap, expectedErrors) = getErrorMapAndExpectedCount(sourceFiles)
772778 val reporter = compile(sourceFiles, flags, true , outDir)
773779 val actualErrors = reporter.errorCount
774-
780+ files.foreach { file =>
781+ if (file.isDirectory) Nil
782+ else {
783+ val checkFile = new JFile (file.getAbsolutePath.reverse.dropWhile(_ != '.' ).reverse + " check" )
784+ checkFileTest(testSource.title, checkFile, reporterOutputLines(reporter))
785+ }
786+ }
775787 if (reporter.compilerCrashed || actualErrors > 0 )
776788 logReporterContents(reporter)
777789
@@ -788,14 +800,13 @@ trait ParallelTesting extends RunnerOrchestration { self =>
788800 if (actualErrors > 0 )
789801 reporters.foreach(logReporterContents)
790802
803+ val checkFile = new JFile (dir.getAbsolutePath.reverse.dropWhile(_ == JFile .separatorChar).reverse + " .check" )
804+ checkFileTest(testSource.title, checkFile, reporters.flatMap(reporter => reporterOutputLines(reporter)))
805+
791806 (compilerCrashed, expectedErrors, actualErrors, () => getMissingExpectedErrors(errorMap, errors), errorMap)
792807 }
793808 }
794809
795- def fail (msg : String ): Unit = {
796- echo(msg)
797- failTestSource(testSource)
798- }
799810
800811 if (compilerCrashed)
801812 fail(s " Compiler crashed when compiling: ${testSource.title}" )
@@ -839,6 +850,24 @@ trait ParallelTesting extends RunnerOrchestration { self =>
839850 }
840851 }
841852
853+ def diffMessage (sourceTitle : String , outputLines : Seq [String ], checkLines : Seq [String ]): Option [String ] = {
854+ def linesMatch =
855+ outputLines
856+ .zip(checkLines)
857+ .forall { case (x, y) => x == y }
858+
859+ if (outputLines.length != checkLines.length || ! linesMatch) {
860+ // Print diff to files and summary:
861+ val diff = DiffUtil .mkColoredLineDiff(checkLines :+ DiffUtil .EOF , outputLines :+ DiffUtil .EOF )
862+
863+ Some (
864+ s """ |Output from ' $sourceTitle' did not match check file.
865+ |Diff (expected on the left, actual right):
866+ | """ .stripMargin + diff + " \n " )
867+ } else None
868+
869+ }
870+
842871 /** The `CompilationTest` is the main interface to `ParallelTesting`, it
843872 * can be instantiated via one of the following methods:
844873 *
0 commit comments