Permalink
Browse files

Ignoring Jenkins concealed ANSI code.

  • Loading branch information...
dblock committed Feb 3, 2012
1 parent 53817d6 commit c804caf8f1f785a0bd0eaf47f231a1f22b8b0356
@@ -31,6 +31,8 @@
import org.fusesource.jansi.AnsiOutputStream;
public class AnsiHtmlOutputStream extends AnsiOutputStream {
private boolean concealOn = false;
@Override
public void close() throws IOException {
@@ -67,10 +69,14 @@ public void writeLine(byte[] buf, int offset, int len) throws IOException {
write(buf, offset, len);
closeAttributes();
}
@Override
protected void processSetAttribute(int attribute) throws IOException {
switch (attribute) {
case ATTRIBUTE_CONCEAL_ON:
write("\u001B[8m");
concealOn = true;
break;
case ATTRIBUTE_INTENSITY_BOLD:
writeAttribute("b");
break;
@@ -92,6 +98,10 @@ protected void processSetAttribute(int attribute) throws IOException {
@Override
protected void processAttributeRest() throws IOException {
if (concealOn) {
write("\u001B[0m");
concealOn = false;
}
closeAttributes();
}
@@ -26,6 +26,8 @@
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import hudson.console.ConsoleNote;
import java.io.IOException;
import org.junit.Test;
@@ -66,6 +68,13 @@ public void testGreenOnWhite() throws IOException {
colorize("hello world"),
is("<span style=\"background-color: white;\"><span style=\"color: green;\">hello world</span></span>"));
}
@Test
public void testConsoleNote() throws IOException {
assertThat(
colorize(ConsoleNote.PREAMBLE_STR + "hello world" + ConsoleNote.POSTAMBLE_STR),
is(ConsoleNote.PREAMBLE_STR + "hello world" + ConsoleNote.POSTAMBLE_STR));
}
private String colorize(String text) throws IOException {
return AnsiColorNote.colorize(text);

0 comments on commit c804caf

Please sign in to comment.