Skip to content

Commit 28cbce5

Browse files
committed
Fix #2245: strip colors from strings before writing to file
1 parent b8ed254 commit 28cbce5

File tree

2 files changed

+6
-14
lines changed

2 files changed

+6
-14
lines changed

compiler/test/dotty/tools/dotc/reporting/TestReporter.scala

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,7 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
2828
private[this] var _didCrash = false
2929
final def compilerCrashed: Boolean = _didCrash
3030

31-
final def flushToFile(): Unit =
32-
_messageBuf
33-
.iterator
34-
.map(_.replaceAll("\u001b\\[.*?m", ""))
35-
.foreach(filePrintln)
36-
37-
final def flushToStdErr(): Unit =
38-
_messageBuf
39-
.iterator
40-
.foreach(System.err.println)
41-
42-
final def inlineInfo(pos: SourcePosition): String =
31+
protected final def inlineInfo(pos: SourcePosition): String =
4332
if (pos.exists) {
4433
if (pos.outer.exists)
4534
s"\ninlined at ${pos.outer}:\n" + inlineInfo(pos.outer)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,14 @@ final class SummaryReport extends SummaryReporting {
131131
if (cleanUps.nonEmpty) cleanUps.foreach(_.apply())
132132
}
133133

134+
private def removeColors(msg: String): String =
135+
msg.replaceAll("\u001b\\[.*?m", "")
136+
134137
def echoToLog(msg: String): Unit =
135-
TestReporter.logPrintln(msg)
138+
TestReporter.logPrintln(removeColors(msg))
136139

137140
def echoToLog(it: Iterator[String]): Unit = {
138-
it.foreach(TestReporter.logPrint)
141+
it.foreach(msg => TestReporter.logPrint(removeColors(msg)))
139142
TestReporter.logFlush()
140143
}
141144
}

0 commit comments

Comments
 (0)