@@ -228,10 +228,17 @@ trait ParallelTesting extends RunnerOrchestration { self =>
228228 * If not, fails the test.
229229 */
230230 final def diffTest (testSource : TestSource , checkFile : JFile , actual : List [String ], reporters : Seq [TestReporter ], logger : LoggedRunnable ) = {
231- val expected = Source .fromFile(checkFile, " UTF-8" ).getLines().toList
232- for (msg <- diffMessage(testSource.title, actual, expected)) {
231+ for (msg <- FileDiff .check(testSource.title, actual, checkFile.getPath)) {
233232 onFailure(testSource, reporters, logger, Some (msg))
234- dumpOutputToFile(checkFile, actual)
233+
234+ if (updateCheckFiles) {
235+ FileDiff .dump(checkFile.toPath.toString, actual)
236+ echo(" Updated checkfile: " + checkFile.getPath)
237+ } else {
238+ val outFile = checkFile.toPath.resolveSibling(checkFile.toPath.getFileName + " .out" ).toString
239+ FileDiff .dump(outFile, actual)
240+ echo(FileDiff .diffMessage(checkFile.getPath, outFile))
241+ }
235242 }
236243 }
237244
@@ -568,24 +575,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
568575 this
569576 }
570577
571- protected def dumpOutputToFile (checkFile : JFile , lines : Seq [String ]): Unit = {
572- if (updateCheckFiles) {
573- val outFile = dotty.tools.io.File (checkFile.toPath)
574- outFile.writeAll(lines.mkString(" " , EOL , EOL ))
575- echo(" Updated checkfile: " + checkFile.getPath)
576- } else {
577- val outFile = dotty.tools.io.File (checkFile.toPath.resolveSibling(checkFile.toPath.getFileName + " .out" ))
578- outFile.writeAll(lines.mkString(" " , EOL , EOL ))
579- echo(
580- s """ Test output dumped in: ${outFile.path}
581- | See diff of the checkfile
582- | > diff $checkFile $outFile
583- | Replace checkfile with current output output
584- | > mv $outFile $checkFile
585- """ .stripMargin)
586- }
587- }
588-
589578 /** Returns all files in directory or the file if not a directory */
590579 private def flattenFiles (f : JFile ): Array [JFile ] =
591580 if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -611,12 +600,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
611600
612601 private def verifyOutput (checkFile : Option [JFile ], dir : JFile , testSource : TestSource , warnings : Int , reporters : Seq [TestReporter ], logger : LoggedRunnable ) = {
613602 if (Properties .testsNoRun) addNoRunWarning()
614- else runMain(testSource.runClassPath) match {
603+ else runMain(testSource.runClassPath) match {
615604 case Success (output) => checkFile match {
616605 case Some (file) if file.exists => diffTest(testSource, file, output.linesIterator.toList, reporters, logger)
617606 case _ =>
618607 }
619- case Failure (output) =>
608+ case Failure (output) =>
620609 echo(s " Test ' ${testSource.title}' failed with output: " )
621610 echo(output)
622611 failTestSource(testSource)
@@ -712,16 +701,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
712701 override def maybeFailureMessage (testSource : TestSource , reporters : Seq [TestReporter ]): Option [String ] = None
713702 }
714703
715- def diffMessage (sourceTitle : String , outputLines : Seq [String ], checkLines : Seq [String ]): Option [String ] = {
716- def linesMatch =
717- (outputLines, checkLines).zipped.forall(_ == _)
718-
719- if (outputLines.length != checkLines.length || ! linesMatch) Some (
720- s """ |Output from ' $sourceTitle' did not match check file. Actual output:
721- | ${outputLines.mkString(EOL )}
722- | """ .stripMargin + " \n " )
723- else None
724- }
725704
726705 /** The `CompilationTest` is the main interface to `ParallelTesting`, it
727706 * can be instantiated via one of the following methods:
0 commit comments