@@ -228,10 +228,17 @@ trait ParallelTesting extends RunnerOrchestration { self =>
228
228
* If not, fails the test.
229
229
*/
230
230
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)) {
233
232
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
+ }
235
242
}
236
243
}
237
244
@@ -568,24 +575,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
568
575
this
569
576
}
570
577
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
-
589
578
/** Returns all files in directory or the file if not a directory */
590
579
private def flattenFiles (f : JFile ): Array [JFile ] =
591
580
if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -611,12 +600,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
611
600
612
601
private def verifyOutput (checkFile : Option [JFile ], dir : JFile , testSource : TestSource , warnings : Int , reporters : Seq [TestReporter ], logger : LoggedRunnable ) = {
613
602
if (Properties .testsNoRun) addNoRunWarning()
614
- else runMain(testSource.runClassPath) match {
603
+ else runMain(testSource.runClassPath) match {
615
604
case Success (output) => checkFile match {
616
605
case Some (file) if file.exists => diffTest(testSource, file, output.linesIterator.toList, reporters, logger)
617
606
case _ =>
618
607
}
619
- case Failure (output) =>
608
+ case Failure (output) =>
620
609
echo(s " Test ' ${testSource.title}' failed with output: " )
621
610
echo(output)
622
611
failTestSource(testSource)
@@ -712,16 +701,6 @@ trait ParallelTesting extends RunnerOrchestration { self =>
712
701
override def maybeFailureMessage (testSource : TestSource , reporters : Seq [TestReporter ]): Option [String ] = None
713
702
}
714
703
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
- }
725
704
726
705
/** The `CompilationTest` is the main interface to `ParallelTesting`, it
727
706
* can be instantiated via one of the following methods:
0 commit comments