File tree Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Expand file tree Collapse file tree 3 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ trait MessageRendering {
21
21
* @return string stripped of ANSI escape codes
22
22
*/
23
23
def stripColor (str : String ): String =
24
- str.replaceAll(" \u001B \\ [[; \\ d]* m" , " " )
24
+ str.replaceAll(" \u001b \\ [.*? m" , " " )
25
25
26
26
/** When inlining a method call, if there's an error we'd like to get the
27
27
* outer context and the `pos` at which the call was inlined.
Original file line number Diff line number Diff line change @@ -58,8 +58,25 @@ object DiffUtil {
58
58
(fnd, exp, totalChange.toDouble / (expected.length + found.length))
59
59
}
60
60
61
- def mkColoredCodeDiff (code : String , lastCode : String , printDiffDel : Boolean ): String = {
61
+ def mkColoredLineDiff (expected : String , actual : String ): String = {
62
+ val tokens = splitTokens(expected, Nil ).toArray
63
+ val lastTokens = splitTokens(actual, Nil ).toArray
64
+
65
+ val diff = hirschberg(lastTokens, tokens)
62
66
67
+ " |SOF\n " + diff.collect {
68
+ case Unmodified (str) =>
69
+ " |" + str
70
+ case Inserted (str) =>
71
+ ADDITION_COLOR + " e |" + str + ANSI_DEFAULT
72
+ case Modified (old, str) =>
73
+ DELETION_COLOR + " a |" + old + " \n e |" + ADDITION_COLOR + str + ANSI_DEFAULT
74
+ case Deleted (str) =>
75
+ DELETION_COLOR + " \n a |" + str + ANSI_DEFAULT
76
+ }.mkString + " \n |EOF"
77
+ }
78
+
79
+ def mkColoredCodeDiff (code : String , lastCode : String , printDiffDel : Boolean ): String = {
63
80
val tokens = splitTokens(code, Nil ).toArray
64
81
val lastTokens = splitTokens(lastCode, Nil ).toArray
65
82
Original file line number Diff line number Diff line change @@ -456,7 +456,7 @@ trait ParallelTesting { self =>
456
456
if (outputLines.length != checkLines.length || ! linesMatch) {
457
457
// Print diff to files and summary:
458
458
val diff = outputLines.zip(checkLines).map { case (act, exp) =>
459
- DiffUtil .mkColoredCodeDiff (exp, act, true )
459
+ DiffUtil .mkColoredLineDiff (exp, act)
460
460
}.mkString(" \n " )
461
461
val msg = s " \n Output from run test ' $checkFile' did not match expected, output: \n $diff\n "
462
462
echo(msg)
You can’t perform that action at this time.
0 commit comments