From 9cfe76e304ceed225798c5aaf748d233f94614ac Mon Sep 17 00:00:00 2001 From: Guillaume Raffin Date: Mon, 11 Jul 2022 18:05:00 +0200 Subject: [PATCH] Fix diff printing in CoverageTests --- .../test/dotty/tools/dotc/coverage/CoverageTests.scala | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala b/compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala index 6db6a330f55e..1a9248c49a82 100644 --- a/compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala +++ b/compiler/test/dotty/tools/dotc/coverage/CoverageTests.scala @@ -15,6 +15,7 @@ import scala.jdk.CollectionConverters.* import scala.util.Properties.userDir import scala.language.unsafeNulls import scala.collection.mutable.Buffer +import dotty.tools.dotc.util.DiffUtil @Category(Array(classOf[BootstrappedOnlyTests])) class CoverageTests: @@ -56,12 +57,8 @@ class CoverageTests: val expected = fixWindowsPaths(Files.readAllLines(expectFile).asScala) val obtained = fixWindowsPaths(Files.readAllLines(targetFile).asScala) if expected != obtained then - // FIXME: zip will drop part of the output if one is shorter (i.e. will not print anything of one is a refix of the other) - for ((exp, actual),i) <- expected.zip(obtained).filter(_ != _).zipWithIndex do - Console.err.println(s"wrong line ${i+1}:") - Console.err.println(s" expected: $exp") - Console.err.println(s" actual : $actual") - fail(s"$targetFile differs from expected $expectFile") + val instructions = FileDiff.diffMessage(expectFile.toString, targetFile.toString) + fail(s"Coverage report differs from expected data.\n$instructions") })