Skip to content

Commit e099f31

Browse files
committed
Make mkColoredLineDiff resizable
1 parent cb1f970 commit e099f31

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

compiler/src/dotty/tools/dotc/util/DiffUtil.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ object DiffUtil {
6161
(fnd, exp, totalChange.toDouble / (expected.length + found.length))
6262
}
6363

64-
def mkColoredLineDiff(expected: String, actual: String): String = {
64+
def mkColoredLineDiff(expected: String, actual: String, expectedSize: Int): String = {
6565
lazy val diff = {
6666
val tokens = splitTokens(expected, Nil).toArray
6767
val lastTokens = splitTokens(actual, Nil).toArray
@@ -90,9 +90,9 @@ object DiffUtil {
9090
DELETION_COLOR + str + ANSI_DEFAULT
9191
}.mkString
9292

93-
val pad = " " * (60 - expected.length).max(0)
93+
val pad = " " * 0.max(expectedSize - expected.length)
9494

95-
expectedDiff + pad + "| " + actualDiff
95+
expectedDiff + pad + " | " + actualDiff
9696
}
9797

9898
def mkColoredCodeDiff(code: String, lastCode: String, printDiffDel: Boolean): String = {

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,9 @@ trait ParallelTesting extends RunnerOrchestration { self =>
511511

512512
if (outputLines.length != checkLines.length || !linesMatch) {
513513
// Print diff to files and summary:
514+
val expectedSize = DiffUtil.EOF.length max outputLines.map(_.length).max
514515
val diff = (outputLines :+ DiffUtil.EOF).zip(checkLines :+ DiffUtil.EOF).map { case (act, exp) =>
515-
DiffUtil.mkColoredLineDiff(exp, act)
516+
DiffUtil.mkColoredLineDiff(exp, act, expectedSize)
516517
}.mkString("\n")
517518

518519
val msg =

0 commit comments

Comments
 (0)