sm test runner: print text with ANSI colors when reading file (IDEA-CR-32979)

This commit is contained in:
Sergey Simonchik
2018-05-25 21:05:48 +03:00
parent f3b7fd6d63
commit 103138328d
@@ -16,6 +16,7 @@
package com.intellij.execution.testframework;
import com.intellij.execution.filters.HyperlinkInfo;
import com.intellij.execution.process.ProcessOutputTypes;
import com.intellij.execution.testframework.stacktrace.DiffHyperlink;
import com.intellij.execution.testframework.ui.TestsOutputConsolePrinter;
import com.intellij.execution.ui.ConsoleViewContentType;
@@ -350,9 +351,7 @@ public class CompositePrintable extends UserDataHolderBase implements Printable,
else {
ConsoleViewContentType contentType = contentTypeByNameMap.getOrDefault(firstToken, ConsoleViewContentType.NORMAL_OUTPUT);
String text = IOUtil.readString(reader);
if (text != null) {
printer.print(text, contentType);
}
printText(printer, text, contentType);
}
lineNum++;
}
@@ -374,6 +373,18 @@ public class CompositePrintable extends UserDataHolderBase implements Printable,
}
}
private void printText(Printer printer, String text, ConsoleViewContentType contentType) {
if (ConsoleViewContentType.NORMAL_OUTPUT.equals(contentType)) {
printer.printWithAnsiColoring(text, ProcessOutputTypes.STDOUT);
}
else if (ConsoleViewContentType.ERROR_OUTPUT.equals(contentType)) {
printer.printWithAnsiColoring(text, ProcessOutputTypes.STDERR);
}
else {
printer.print(text, contentType);
}
}
private boolean wasPrintableChanged(Printer printer) {
return printer instanceof TestsOutputConsolePrinter && !((TestsOutputConsolePrinter)printer).isCurrent(CompositePrintable.this);
}