Skip to content

Fix #2245: strip colors from strings before writing to file #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions compiler/test/dotty/tools/dotc/reporting/TestReporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,7 @@ extends Reporter with UniqueMessagePositions with HideNonSensicalMessages with M
private[this] var _didCrash = false
final def compilerCrashed: Boolean = _didCrash

final def flushToFile(): Unit =
_messageBuf
.iterator
.map(_.replaceAll("\u001b\\[.*?m", ""))
.foreach(filePrintln)

final def flushToStdErr(): Unit =
_messageBuf
.iterator
.foreach(System.err.println)

final def inlineInfo(pos: SourcePosition): String =
protected final def inlineInfo(pos: SourcePosition): String =
if (pos.exists) {
if (pos.outer.exists)
s"\ninlined at ${pos.outer}:\n" + inlineInfo(pos.outer)
Expand Down
7 changes: 5 additions & 2 deletions compiler/test/dotty/tools/vulpix/SummaryReport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,14 @@ final class SummaryReport extends SummaryReporting {
if (cleanUps.nonEmpty) cleanUps.foreach(_.apply())
}

private def removeColors(msg: String): String =
msg.replaceAll("\u001b\\[.*?m", "")

def echoToLog(msg: String): Unit =
TestReporter.logPrintln(msg)
TestReporter.logPrintln(removeColors(msg))

def echoToLog(it: Iterator[String]): Unit = {
it.foreach(TestReporter.logPrint)
it.foreach(msg => TestReporter.logPrint(removeColors(msg)))
TestReporter.logFlush()
}
}
Expand Down