From 6d3e730e7a0d98da8dab49e41827eefd98a4bb8a Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 1 Nov 2018 12:25:30 -0400 Subject: [PATCH 1/5] Removing use of LineTransformationOutputStream. --- .../ansicolor/AnsiColorConsoleLogFilter.java | 41 ++++++------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java index e318629..0be0123 100644 --- a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java +++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java @@ -1,7 +1,6 @@ package hudson.plugins.ansicolor; import hudson.console.ConsoleLogFilter; -import hudson.console.LineTransformationOutputStream; import hudson.model.AbstractBuild; import java.io.ByteArrayOutputStream; @@ -68,36 +67,20 @@ public OutputStream decorateLogger(AbstractBuild build, final OutputStream logge return null; } - return new LineTransformationOutputStream() { - AnsiHtmlOutputStream ansi = new AnsiHtmlOutputStream(logger, colorMap, new AnsiAttributeElement.Emitter() { - @Override - public void emitHtml(String html) { - try { - byte[] pregenerated = notes.get(html); - if (pregenerated != null) { - logger.write(pregenerated); - } else { - new SimpleHtmlNote(html).encodeTo(logger); - } - } catch (IOException e) { - LOG.log(Level.WARNING, "Failed to add HTML markup '" + html + "'", e); + return new AnsiHtmlOutputStream(logger, colorMap, new AnsiAttributeElement.Emitter() { + @Override + public void emitHtml(String html) { + try { + byte[] pregenerated = notes.get(html); + if (pregenerated != null) { + logger.write(pregenerated); + } else { + new SimpleHtmlNote(html).encodeTo(logger); } + } catch (IOException e) { + LOG.log(Level.WARNING, "Failed to add HTML markup '" + html + "'", e); } - }); - - @Override - protected void eol(byte[] b, int len) throws IOException { - ansi.write(b, 0, len); - ansi.flush(); - logger.flush(); - } - - @Override - public void close() throws IOException { - ansi.close(); - logger.close(); - super.close(); } - }; + }); } } From d73554970011f52aa682701457a6146742251f35 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 1 Nov 2018 13:15:37 -0400 Subject: [PATCH 2/5] AnsiColorConsoleLogFilterTest to improve test coverage. --- .../ansicolor/AnsiColorConsoleLogFilter.java | 1 + .../AnsiColorConsoleLogFilterTest.java | 218 ++++++++++++++++++ .../ansicolor/AnsiHtmlOutputStreamTest.java | 2 +- 3 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java index 0be0123..eeb5824 100644 --- a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java +++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java @@ -75,6 +75,7 @@ public void emitHtml(String html) { if (pregenerated != null) { logger.write(pregenerated); } else { + // TODO decline to use pregenerated form of end tag if start tag could not be pregenerated new SimpleHtmlNote(html).encodeTo(logger); } } catch (IOException e) { diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java new file mode 100644 index 0000000..28f074f --- /dev/null +++ b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java @@ -0,0 +1,218 @@ +/* + * The MIT License + * + * Copyright 2018 CloudBees, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +package hudson.plugins.ansicolor; + +import hudson.console.ConsoleAnnotationOutputStream; +import hudson.model.AbstractBuild; +import hudson.model.TaskListener; +import hudson.slaves.DumbSlave; +import hudson.util.StreamTaskListener; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.io.StringWriter; +import java.nio.charset.StandardCharsets; +import java.util.logging.Level; +import jenkins.security.MasterToSlaveCallable; +import org.jenkinsci.plugins.workflow.log.ConsoleAnnotators; +import org.junit.AssumptionViolatedException; // Ignore seems to be ignored in this context +import org.junit.ClassRule; +import org.junit.BeforeClass; +import org.jvnet.hudson.test.Issue; +import org.jvnet.hudson.test.JenkinsRule; +import org.jvnet.hudson.test.LoggerRule; + +/** + * Checks which kinds of console notes are successfully pregenerated for use in a remoted filter. + */ +@Issue("JENKINS-54133") +public class AnsiColorConsoleLogFilterTest extends AnsiHtmlOutputStreamTest { + + @ClassRule + public static LoggerRule logging = new LoggerRule().record(AnsiColorConsoleLogFilter.class, Level.FINE); + + @ClassRule + public static JenkinsRule r = new JenkinsRule(); + + private static DumbSlave s; + + @BeforeClass + public static void createSlave() throws Exception { + s = r.createOnlineSlave(); + } + + @Override + protected String annotate(String text, AnsiColorMap colorMap) throws IOException { + StringWriter sw = new StringWriter(); + try (OutputStream caos = new ConsoleAnnotationOutputStream(sw, ConsoleAnnotators.createAnnotator(null), null, StandardCharsets.UTF_8); + StreamTaskListener listener = new StreamTaskListener(caos)) { + s.getChannel().call(new AnnotateCallable(text, listener, new AnsiColorConsoleLogFilter(colorMap))); + } catch (IOException x) { + throw x; + } catch (Exception x) { + throw new IOException(x); + } + return sw.toString(); + } + + private static final class AnnotateCallable extends MasterToSlaveCallable { + + private final String text; + private final TaskListener listener; + private final AnsiColorConsoleLogFilter filter; + + AnnotateCallable(String text, TaskListener listener, AnsiColorConsoleLogFilter filter) { + this.text = text; + this.listener = listener; + this.filter = filter; + } + + @Override + public Void call() throws Exception { + try (OutputStream decorated = filter.decorateLogger((AbstractBuild) null, listener.getLogger()); + PrintStream ps = new PrintStream(decorated)) { + ps.print(text); + } + return null; + } + + } + + @Override + public void testDefaultColors() throws IOException { + throw new AssumptionViolatedException("TODO missing background-color"); + } + + @Override + public void testEmbeddedConsoleNote() throws IOException { + throw new AssumptionViolatedException("seems irrelevant"); + } + + @Override + public void testBold() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testOverlapping() throws IOException { + throw new AssumptionViolatedException("TODO missing some things"); + } + + @Override + public void testResetForegroundColor() throws IOException { + throw new AssumptionViolatedException("TODO missing bold"); + } + + @Override + public void testUnderline() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testOverlined() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testForegroundColor256() throws IOException { + throw new AssumptionViolatedException("other than the standard colors, which could be split into a separate test, seems unimplementable"); + } + + @Override + public void testForegroundColorRgb() throws IOException { + throw new AssumptionViolatedException("probably unimplementable"); + } + + @Override + public void testStrikeout() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testForegroundColorHighIntensity() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testGreenOnWhite() throws IOException { + throw new AssumptionViolatedException("TODO missing background-color"); + } + + @Override + public void testBackgroundColorHighIntensity() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testGreenOnWhiteXTerm() throws IOException { + throw new AssumptionViolatedException("TODO missing background-color"); + } + + @Override + public void testFramed() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testItalic() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testResetBackgroundColor() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testNegative() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + + @Override + public void testConsoleNote() throws IOException { + throw new AssumptionViolatedException("seems irrelevant"); + } + + @Override + public void testGreenOnWhiteCSS() throws IOException { + throw new AssumptionViolatedException("TODO missing background-color"); + } + + @Override + public void testBackgroundColor256() throws IOException { + throw new AssumptionViolatedException("other than the standard colors, which could be split into a separate test, seems unimplementable"); + } + + @Override + public void testBackgroundColorRgb() throws IOException { + throw new AssumptionViolatedException("probably unimplementable"); + } + + @Override + public void testUnderlineDouble() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); + } + +} diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java index cae6af7..b544e74 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiHtmlOutputStreamTest.java @@ -610,7 +610,7 @@ private void assertThatAnnotateIs(AnsiColorMap colorMap, String ansi, String htm assertThat(annotate(ansi, colorMap), is(html)); } - private String annotate(String text, AnsiColorMap colorMap) throws IOException { + protected String annotate(String text, AnsiColorMap colorMap) throws IOException { final ByteArrayOutputStream bos = new ByteArrayOutputStream(); AnsiHtmlOutputStream ansi = new AnsiHtmlOutputStream(bos, colorMap, new AnsiAttributeElement.Emitter() { public void emitHtml(String html) { From 99881727a9e70482fd41b6606ed7657f8f9f9b35 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 1 Nov 2018 13:25:37 -0400 Subject: [PATCH 3/5] Keep skipped tests in same order as in superclass, rather than in quasi-random execution order. --- .../AnsiColorConsoleLogFilterTest.java | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java index 28f074f..de23fe4 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java @@ -100,11 +100,6 @@ public Void call() throws Exception { } - @Override - public void testDefaultColors() throws IOException { - throw new AssumptionViolatedException("TODO missing background-color"); - } - @Override public void testEmbeddedConsoleNote() throws IOException { throw new AssumptionViolatedException("seems irrelevant"); @@ -116,42 +111,37 @@ public void testBold() throws IOException { } @Override - public void testOverlapping() throws IOException { - throw new AssumptionViolatedException("TODO missing some things"); - } - - @Override - public void testResetForegroundColor() throws IOException { - throw new AssumptionViolatedException("TODO missing bold"); + public void testUnderline() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testUnderline() throws IOException { + public void testUnderlineDouble() throws IOException { throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testOverlined() throws IOException { + public void testItalic() throws IOException { throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testForegroundColor256() throws IOException { - throw new AssumptionViolatedException("other than the standard colors, which could be split into a separate test, seems unimplementable"); + public void testNegative() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testForegroundColorRgb() throws IOException { - throw new AssumptionViolatedException("probably unimplementable"); + public void testStrikeout() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testStrikeout() throws IOException { + public void testFramed() throws IOException { throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testForegroundColorHighIntensity() throws IOException { + public void testOverlined() throws IOException { throw new AssumptionViolatedException("TODO not implemented"); } @@ -161,8 +151,8 @@ public void testGreenOnWhite() throws IOException { } @Override - public void testBackgroundColorHighIntensity() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); + public void testGreenOnWhiteCSS() throws IOException { + throw new AssumptionViolatedException("TODO missing background-color"); } @Override @@ -171,33 +161,33 @@ public void testGreenOnWhiteXTerm() throws IOException { } @Override - public void testFramed() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); + public void testResetForegroundColor() throws IOException { + throw new AssumptionViolatedException("TODO missing bold"); } @Override - public void testItalic() throws IOException { + public void testForegroundColorHighIntensity() throws IOException { throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testResetBackgroundColor() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); + public void testForegroundColor256() throws IOException { + throw new AssumptionViolatedException("other than the standard colors, which could be split into a separate test, seems unimplementable"); } @Override - public void testNegative() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); + public void testForegroundColorRgb() throws IOException { + throw new AssumptionViolatedException("probably unimplementable"); } @Override - public void testConsoleNote() throws IOException { - throw new AssumptionViolatedException("seems irrelevant"); + public void testResetBackgroundColor() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); } @Override - public void testGreenOnWhiteCSS() throws IOException { - throw new AssumptionViolatedException("TODO missing background-color"); + public void testBackgroundColorHighIntensity() throws IOException { + throw new AssumptionViolatedException("TODO not implemented"); } @Override @@ -211,8 +201,18 @@ public void testBackgroundColorRgb() throws IOException { } @Override - public void testUnderlineDouble() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); + public void testDefaultColors() throws IOException { + throw new AssumptionViolatedException("TODO missing background-color"); + } + + @Override + public void testConsoleNote() throws IOException { + throw new AssumptionViolatedException("seems irrelevant"); + } + + @Override + public void testOverlapping() throws IOException { + throw new AssumptionViolatedException("TODO missing some things"); } } From 3395bc20ba1d01b6495e58863240e73ed9a3bd1f Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 1 Nov 2018 13:36:59 -0400 Subject: [PATCH 4/5] Fixing the easy cases of text formatting. --- .../ansicolor/AnsiAttributeElement.java | 30 ++++++++++++++++ .../ansicolor/AnsiColorConsoleLogFilter.java | 7 ++++ .../ansicolor/AnsiHtmlOutputStream.java | 15 ++++---- .../AnsiColorConsoleLogFilterTest.java | 35 ------------------- 4 files changed, 44 insertions(+), 43 deletions(-) diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiAttributeElement.java b/src/main/java/hudson/plugins/ansicolor/AnsiAttributeElement.java index a418756..4adfd7d 100644 --- a/src/main/java/hudson/plugins/ansicolor/AnsiAttributeElement.java +++ b/src/main/java/hudson/plugins/ansicolor/AnsiAttributeElement.java @@ -64,4 +64,34 @@ public int hashCode() { result = 31 * result + attributes.hashCode(); return result; } + + public static AnsiAttributeElement bold() { + return new AnsiAttributeElement(AnsiAttributeElement.AnsiAttrType.BOLD, "b", ""); + } + + public static AnsiAttributeElement italic() { + return new AnsiAttributeElement(AnsiAttrType.ITALIC, "i", ""); + } + + public static AnsiAttributeElement underline() { + return new AnsiAttributeElement(AnsiAttrType.UNDERLINE, "u", ""); + } + + public static AnsiAttributeElement underlineDouble() { + return new AnsiAttributeElement(AnsiAttrType.UNDERLINE, "span", "style=\"border-bottom: 3px double;\""); + } + + public static AnsiAttributeElement strikeout() { + return new AnsiAttributeElement(AnsiAttrType.STRIKEOUT, "span", "style=\"text-decoration: line-through;\""); + } + + public static AnsiAttributeElement framed() { + return new AnsiAttributeElement(AnsiAttrType.FRAMED, "span", "style=\"border: 1px solid;\""); + } + + public static AnsiAttributeElement overline() { + return new AnsiAttributeElement(AnsiAttrType.OVERLINE, "span", "style=\"text-decoration: overline;\""); + // return new AnsiAttributeElement(AnsiAttrType.OVERLINE, "span", "style=\"border-top: 1px solid;\""); // alternate approach + } + } diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java index eeb5824..aca63cb 100644 --- a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java +++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java @@ -33,6 +33,13 @@ public AnsiColorConsoleLogFilter(AnsiColorMap colorMap) { for (AnsiColorMap.Color color : AnsiColorMap.Color.values()) { pregenerateNote(new AnsiAttributeElement(AnsiAttributeElement.AnsiAttrType.FG, "span", "style=\"color: " + colorMap.getNormal(color.ordinal()) + ";\"")); } + pregenerateNote(AnsiAttributeElement.bold()); + pregenerateNote(AnsiAttributeElement.italic()); + pregenerateNote(AnsiAttributeElement.underline()); + pregenerateNote(AnsiAttributeElement.underlineDouble()); + pregenerateNote(AnsiAttributeElement.strikeout()); + pregenerateNote(AnsiAttributeElement.framed()); + pregenerateNote(AnsiAttributeElement.overline()); // TODO other cases, and other methods LOG.log(Level.FINE, "Notes pregenerated for {0}", notes.keySet()); } diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiHtmlOutputStream.java b/src/main/java/hudson/plugins/ansicolor/AnsiHtmlOutputStream.java index 7044305..7a693de 100644 --- a/src/main/java/hudson/plugins/ansicolor/AnsiHtmlOutputStream.java +++ b/src/main/java/hudson/plugins/ansicolor/AnsiHtmlOutputStream.java @@ -391,28 +391,28 @@ else switch (attribute) { break; case ATTRIBUTE_INTENSITY_BOLD: closeTagOfType(AnsiAttrType.BOLD); - openTag(new AnsiAttributeElement(AnsiAttrType.BOLD, "b", "")); + openTag(AnsiAttributeElement.bold()); break; case ATTRIBUTE_INTENSITY_NORMAL: closeTagOfType(AnsiAttrType.BOLD); break; case ATTRIBUTE_ITALIC: closeTagOfType(AnsiAttrType.ITALIC); - openTag(new AnsiAttributeElement(AnsiAttrType.ITALIC, "i", "")); + openTag(AnsiAttributeElement.italic()); break; case ATTRIBUTE_ITALIC_OFF: closeTagOfType(AnsiAttrType.ITALIC); break; case ATTRIBUTE_UNDERLINE: closeTagOfType(AnsiAttrType.UNDERLINE); - openTag(new AnsiAttributeElement(AnsiAttrType.UNDERLINE, "u", "")); + openTag(AnsiAttributeElement.underline()); break; case ATTRIBUTE_UNDERLINE_DOUBLE: // Double underlining is handled entirely different from single underlining, by using a CSS border // instead of a u-element, but it's still of the same attribute type and previously opened elements of // either type are closed accordingly. closeTagOfType(AnsiAttrType.UNDERLINE); - openTag(new AnsiAttributeElement(AnsiAttrType.UNDERLINE, "span", "style=\"border-bottom: 3px double;\"")); + openTag(AnsiAttributeElement.underlineDouble()); break; case ATTRIBUTE_UNDERLINE_OFF: closeTagOfType(AnsiAttrType.UNDERLINE); @@ -447,7 +447,7 @@ else switch (attribute) { // alternatives are (both tested and successfully rendered in firefox 51.0.1) // but I finally decide for "text-decoration: line-through" closeTagOfType(AnsiAttrType.STRIKEOUT); - openTag(new AnsiAttributeElement(AnsiAttrType.STRIKEOUT, "span", "style=\"text-decoration: line-through;\"")); + openTag(AnsiAttributeElement.strikeout()); // openTag(new AnsiAttributeElement(AnsiAttrType.STRIKEOUT, "s", "")); // alternate approach break; case ATTRIBUTE_STRIKEOUT_OFF: @@ -455,15 +455,14 @@ else switch (attribute) { break; case ATTRIBUTE_FRAMED: closeTagOfType(AnsiAttrType.FRAMED); - openTag(new AnsiAttributeElement(AnsiAttrType.FRAMED, "span", "style=\"border: 1px solid;\"")); + openTag(AnsiAttributeElement.framed()); break; case ATTRIBUTE_FRAMED_OFF: closeTagOfType(AnsiAttrType.FRAMED); break; case ATTRIBUTE_OVERLINE: closeTagOfType(AnsiAttrType.OVERLINE); - openTag(new AnsiAttributeElement(AnsiAttrType.OVERLINE, "span", "style=\"text-decoration: overline;\"")); - //openTag(new AnsiAttributeElement(AnsiAttrType.OVERLINE, "span", "style=\"border-top: 1px solid;\"")); // alternate approach + openTag(AnsiAttributeElement.overline()); break; case ATTRIBUTE_OVERLINE_OFF: closeTagOfType(AnsiAttrType.OVERLINE); diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java index de23fe4..3d939b0 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java @@ -105,46 +105,11 @@ public void testEmbeddedConsoleNote() throws IOException { throw new AssumptionViolatedException("seems irrelevant"); } - @Override - public void testBold() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - - @Override - public void testUnderline() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - - @Override - public void testUnderlineDouble() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - - @Override - public void testItalic() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - @Override public void testNegative() throws IOException { throw new AssumptionViolatedException("TODO not implemented"); } - @Override - public void testStrikeout() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - - @Override - public void testFramed() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - - @Override - public void testOverlined() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - @Override public void testGreenOnWhite() throws IOException { throw new AssumptionViolatedException("TODO missing background-color"); From 94d289da0c7c0509e104b850dc7e477802e72eb4 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Thu, 1 Nov 2018 13:42:11 -0400 Subject: [PATCH 5/5] Handle bright colors. --- .../hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java | 1 + .../plugins/ansicolor/AnsiColorConsoleLogFilterTest.java | 5 ----- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java index aca63cb..646f5f8 100644 --- a/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java +++ b/src/main/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilter.java @@ -32,6 +32,7 @@ public AnsiColorConsoleLogFilter(AnsiColorMap colorMap) { // some cases of AnsiHtmlOutputStream.setForegroundColor: for (AnsiColorMap.Color color : AnsiColorMap.Color.values()) { pregenerateNote(new AnsiAttributeElement(AnsiAttributeElement.AnsiAttrType.FG, "span", "style=\"color: " + colorMap.getNormal(color.ordinal()) + ";\"")); + pregenerateNote(new AnsiAttributeElement(AnsiAttributeElement.AnsiAttrType.FG, "span", "style=\"color: " + colorMap.getBright(color.ordinal()) + ";\"")); } pregenerateNote(AnsiAttributeElement.bold()); pregenerateNote(AnsiAttributeElement.italic()); diff --git a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java index 3d939b0..b116048 100644 --- a/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java +++ b/src/test/java/hudson/plugins/ansicolor/AnsiColorConsoleLogFilterTest.java @@ -130,11 +130,6 @@ public void testResetForegroundColor() throws IOException { throw new AssumptionViolatedException("TODO missing bold"); } - @Override - public void testForegroundColorHighIntensity() throws IOException { - throw new AssumptionViolatedException("TODO not implemented"); - } - @Override public void testForegroundColor256() throws IOException { throw new AssumptionViolatedException("other than the standard colors, which could be split into a separate test, seems unimplementable");