@@ -505,6 +505,12 @@ trait ParallelTesting extends RunnerOrchestration { self =>
505505 this
506506 }
507507
508+ protected def updateCheckFile (checkFile : JFile , lines : Seq [String ]): Unit = {
509+ val outFile = dotty.tools.io.File (checkFile.toPath)
510+ outFile.writeAll(lines.mkString(" " , EOL , EOL ))
511+ echo(" Updated checkfile: " + checkFile.getPath)
512+ }
513+
508514 /** Returns all files in directory or the file if not a directory */
509515 private def flattenFiles (f : JFile ): Array [JFile ] =
510516 if (f.isDirectory) f.listFiles.flatMap(flattenFiles)
@@ -537,28 +543,32 @@ trait ParallelTesting extends RunnerOrchestration { self =>
537543 val output = Source .fromFile(outDir.getParent + " _decompiled" + JFile .separator + outDir.getName
538544 + JFile .separator + " decompiled.scala" , " UTF-8" ).getLines().map {line =>
539545 stripTrailingWhitespaces.unapplySeq(line).map(_.head).getOrElse(line)
540- }.toList
546+ }.filter( ! _.startsWith(ignoredFilePathLine)). toList
541547
542- val check : String = Source .fromFile(checkFile, " UTF-8" ).getLines().filter( ! _.startsWith(ignoredFilePathLine))
548+ val check : String = Source .fromFile(checkFile, " UTF-8" ).getLines()
543549 .mkString(EOL )
544550
545- if (output.filter( ! _.startsWith(ignoredFilePathLine)). mkString(EOL ) != check) {
551+ if (output.mkString(EOL ) != check) {
546552 val outFile = dotty.tools.io.File (checkFile.toPath).addExtension(" .out" )
547- outFile.writeAll(output.mkString(EOL ))
548- val msg =
549- s """ Output differed for test $name, use the following command to see the diff:
550- | > diff $checkFile $outFile
553+ if (summaryReport.updateCheckFiles) {
554+ updateCheckFile(checkFile, output)
555+ } else {
556+ outFile.writeAll(output.mkString(" " , EOL , " " ))
557+ val msg =
558+ s """ Output differed for test $name, use the following command to see the diff:
559+ | > diff $checkFile $outFile
551560 """ .stripMargin
552561
553- echo(msg)
554- addFailureInstruction(msg)
562+ echo(msg)
563+ addFailureInstruction(msg)
555564
556- // Print build instructions to file and summary:
557- val buildInstr = testSource.buildInstructions(0 , rep.warningCount)
558- addFailureInstruction(buildInstr)
565+ // Print build instructions to file and summary:
566+ val buildInstr = testSource.buildInstructions(0 , rep.warningCount)
567+ addFailureInstruction(buildInstr)
559568
560- // Fail target:
561- failTestSource(testSource)
569+ // Fail target:
570+ failTestSource(testSource)
571+ }
562572 }
563573 case _ =>
564574 }
@@ -631,6 +641,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
631641
632642 // Fail target:
633643 failTestSource(testSource)
644+
645+ if (summaryReport.updateCheckFiles)
646+ updateCheckFile(checkFile.get, outputLines)
634647 }
635648 }
636649
@@ -766,7 +779,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
766779 }
767780 def checkFileTest (sourceName : String , checkFile : JFile , actual : List [String ]) = {
768781 val expexted = Source .fromFile(checkFile, " UTF-8" ).getLines().toList
769- diffMessage(sourceName, actual, expexted).foreach(fail)
782+ for (msg <- diffMessage(sourceName, actual, expexted)) {
783+ fail(msg)
784+ if (summaryReport.updateCheckFiles)
785+ updateCheckFile(checkFile, actual)
786+ }
770787 }
771788
772789 val (compilerCrashed, expectedErrors, actualErrors, hasMissingAnnotations, errorMap) = testSource match {
0 commit comments