@@ -514,10 +514,22 @@ trait ParallelTesting extends RunnerOrchestration { self =>
514514 this
515515 }
516516
517- protected def updateCheckFile (checkFile : JFile , lines : Seq [String ]): Unit = {
518- val outFile = dotty.tools.io.File (checkFile.toPath)
519- outFile.writeAll(lines.mkString(" " , EOL , EOL ))
520- echo(" Updated checkfile: " + checkFile.getPath)
517+ protected def dumpOutputToFile (checkFile : JFile , lines : Seq [String ]): Unit = {
518+ if (updateCheckFiles) {
519+ val outFile = dotty.tools.io.File (checkFile.toPath)
520+ outFile.writeAll(lines.mkString(" " , EOL , EOL ))
521+ echo(" Updated checkfile: " + checkFile.getPath)
522+ } else {
523+ val outFile = dotty.tools.io.File (checkFile.toPath.resolveSibling(checkFile.toPath.getFileName + " .out" ))
524+ outFile.writeAll(lines.mkString(" " , EOL , EOL ))
525+ echo(
526+ s """ Test output dumped in: ${outFile.path}
527+ | See diff of the checkfile
528+ | > diff $checkFile $outFile
529+ | Replace checkfile with current output output
530+ | > mv $outFile $checkFile
531+ """ .stripMargin)
532+ }
521533 }
522534
523535 /** Returns all files in directory or the file if not a directory */
@@ -558,26 +570,15 @@ trait ParallelTesting extends RunnerOrchestration { self =>
558570 .mkString(EOL )
559571
560572 if (output.mkString(EOL ) != check) {
561- val outFile = dotty.tools.io.File (checkFile.toPath).addExtension(" .out" )
562- if (updateCheckFiles) {
563- updateCheckFile(checkFile, output)
564- } else {
565- outFile.writeAll(output.mkString(" " , EOL , " " ))
566- val msg =
567- s """ Output differed for test $name, use the following command to see the diff:
568- | > diff $checkFile $outFile
569- """ .stripMargin
570-
571- echo(msg)
572- addFailureInstruction(msg)
573-
574- // Print build instructions to file and summary:
575- val buildInstr = testSource.buildInstructions(0 , rep.warningCount)
576- addFailureInstruction(buildInstr)
577-
578- // Fail target:
579- failTestSource(testSource)
580- }
573+
574+ dumpOutputToFile(checkFile, output)
575+
576+ // Print build instructions to file and summary:
577+ val buildInstr = testSource.buildInstructions(0 , rep.warningCount)
578+ addFailureInstruction(buildInstr)
579+
580+ // Fail target:
581+ failTestSource(testSource)
581582 }
582583 case _ =>
583584 }
@@ -651,8 +652,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
651652 // Fail target:
652653 failTestSource(testSource)
653654
654- if (updateCheckFiles)
655- updateCheckFile(checkFile.get, outputLines)
655+ dumpOutputToFile(checkFile.get, outputLines)
656656 }
657657 }
658658
@@ -790,8 +790,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
790790 val expexted = Source .fromFile(checkFile, " UTF-8" ).getLines().toList
791791 for (msg <- diffMessage(sourceName, actual, expexted)) {
792792 fail(msg)
793- if (updateCheckFiles)
794- updateCheckFile(checkFile, actual)
793+ dumpOutputToFile(checkFile, actual)
795794 }
796795 }
797796
0 commit comments