Skip to content

Commit

Permalink
Merge pull request #183 from tszmytka/master
Browse files Browse the repository at this point in the history
Clean up and prepare for release 0.7.0
  • Loading branch information
tszmytka authored May 23, 2020
2 parents 25e9865 + b0a1bd1 commit 29b8136
Show file tree
Hide file tree
Showing 8 changed files with 63 additions and 47 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
root = true

[*]
charset = utf-8
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
max_line_length = 200

[*.xml]
indent_size = 2
3 changes: 1 addition & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
0.7.0 (Next)
0.7.0 (05/23/2020)
============

* [#173](https://github.com/jenkinsci/ansicolor-plugin/pull/173): Fix for SGR Normal intensity not handled correctly - [@tszmytka](https://github.com/tszmytka).
* [#176](https://github.com/jenkinsci/ansicolor-plugin/pull/176): Ensure extended color SGRs are recognized correctly - [@tszmytka](https://github.com/tszmytka).
* [#156](https://github.com/jenkinsci/ansicolor-plugin/pull/156): Improve documentation - [@tszmytka](https://github.com/tszmytka).
* [#181](https://github.com/jenkinsci/ansicolor-plugin/pull/181): Re-implement support for multiple ansiColor steps within one pipeline script - [@tszmytka](https://github.com/tszmytka).
* Your contribution here.

0.6.3 (02/24/2020)
============
Expand Down
8 changes: 6 additions & 2 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@ mvn test

Check that the last build succeeded in [Travis CI](https://travis-ci.org/jenkinsci/ansicolor-plugin).

Ensure that the version in [pom.xml](pom.xml) is correct and ends with `-SNAPSHOT`.
Ensure that the version in [pom.xml](pom.xml) is correct and effectively ends with `-SNAPSHOT`.

``` xml
<artifactId>ansicolor</artifactId>
<version>${revision}${changelist}</version>
<packaging>hpi</packaging>
<version>0.4.1-SNAPSHOT</version>
<properties>
<revision>0.7.0</revision>
<changelist>-SNAPSHOT</changelist>
</properties>
```

Change "Next Release" in [CHANGELOG.md](CHANGELOG.md) to the new version.
Expand Down
15 changes: 8 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.1</version>
<relativePath />
<version>4.2</version>
<relativePath/>
</parent>

<artifactId>ansicolor</artifactId>
Expand Down Expand Up @@ -40,17 +41,17 @@
</scm>

<properties>
<revision>0.6.4</revision>
<revision>0.7.0</revision>
<changelist>-SNAPSHOT</changelist>
<jenkins.version>2.176.3</jenkins.version>
<java.level>8</java.level>
</properties>

<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<optional>true</optional>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
import java.util.logging.Level;
import java.util.stream.Collectors;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;

public class AnsiColorBuildWrapperTest {
private static final String ESC = "\033";
Expand Down Expand Up @@ -114,7 +116,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
FreeStyleBuild b = r.buildAndAssertSuccess(p);
StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
System.out.print(html);
assertThat(
Expand Down Expand Up @@ -143,7 +145,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
FreeStyleBuild b = r.buildAndAssertSuccess(p);
StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
System.out.print(html);
String nl = System.lineSeparator();
Expand Down Expand Up @@ -175,7 +177,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
FreeStyleBuild b = r.buildAndAssertSuccess(p);
StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
System.out.print(html);
String nl = System.lineSeparator();
Expand Down Expand Up @@ -210,10 +212,11 @@ public void evaluate() throws Throwable {
+ " )\n"
+ " }\n"
+ "}"
, false
));
story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
StringWriter writer = new StringWriter();
p.getLastBuild().getLogText().writeHtmlTo(0L, writer);
assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
assertTrue(
"Failed to match color attribute in following HTML log output:\n" + html,
Expand All @@ -240,7 +243,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
FreeStyleBuild b = r.buildAndAssertSuccess(p);
StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
assertThat(
html.replaceAll("<!--.+?-->", ""),
Expand Down Expand Up @@ -272,7 +275,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
FreeStyleBuild b = r.buildAndAssertSuccess(p);
StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
System.out.print(html);
assertThat(
Expand Down Expand Up @@ -301,7 +304,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
FreeStyleBuild b = r.buildAndAssertSuccess(p);
StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
System.out.print(html);
assertThat(
Expand Down Expand Up @@ -435,9 +438,7 @@ public void canRenderSgrFaintIntensity() {
public void canHandleSgrsWithMultipleOptions() {
final String input = "\u001B[33mbanana_1 |\u001B[0m 19:59:14.353\u001B[0;38m [debug] Lager installed handler {lager_file_backend,\"banana.log\"} into lager_event\u001B[0m\n";

final Consumer<PrintStream> inputProvider = stream -> {
stream.println(input);
};
final Consumer<PrintStream> inputProvider = stream -> stream.println(input);

assertCorrectOutput(
Collections.singletonList("<span style=\"color: #CDCD00;\">banana_1 |</span> 19:59:14.353 [debug] Lager installed handler {lager_file_backend,\"banana.log\"} into lager_event"),
Expand Down Expand Up @@ -486,7 +487,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen
});
final FreeStyleBuild b = rule.buildAndAssertSuccess(p);
final StringWriter writer = new StringWriter();
b.getLogText().writeHtmlTo(0L, writer);
assertTrue(b.getLogText().writeHtmlTo(0L, writer) > 0);
return writer.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void evaluate() throws Throwable {
, true));
WorkflowRun run = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
StringWriter writer = new StringWriter();
p.getLastBuild().getLogText().writeHtmlTo(0L, writer);
assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
story.j.assertLogContains("TERM=xterm", run);
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,16 @@
*/
package hudson.plugins.ansicolor;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

import hudson.console.ConsoleNote;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import org.junit.Test;

import javax.annotation.Nonnull;
import java.io.ByteArrayOutputStream;
import java.io.IOException;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat;

public class AnsiHtmlOutputStreamTest {

Expand Down Expand Up @@ -617,15 +618,15 @@ private String annotate(String text, AnsiColorMap colorMap) throws IOException {
AnsiHtmlOutputStream ansi = new AnsiHtmlOutputStream(bos, colorMap, new AnsiAttributeElement.Emitter() {
public void emitHtml(@Nonnull String html) {
try {
bos.write(html.getBytes("UTF-8"));
bos.write(html.getBytes(UTF_8));
} catch (IOException e) {
throw new RuntimeException("error emitting HTML", e);
}
}
});
ansi.write(text.getBytes("UTF-8"));
ansi.write(text.getBytes(UTF_8));
ansi.close();
return bos.toString("UTF-8");
return bos.toString(UTF_8.displayName());
}

private String annotate(String text) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
package hudson.plugins.ansicolor;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.io.StringWriter;
import java.util.logging.Level;

import jenkins.model.Jenkins;
import org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition;
import org.jenkinsci.plugins.workflow.job.WorkflowJob;
import org.jenkinsci.plugins.workflow.job.WorkflowRun;
import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
Expand All @@ -18,7 +11,11 @@
import org.jvnet.hudson.test.LoggerRule;
import org.jvnet.hudson.test.RestartableJenkinsRule;

import jenkins.model.Jenkins;
import java.io.StringWriter;
import java.util.logging.Level;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class ColorConsoleAnnotatorTest {

Expand All @@ -33,7 +30,7 @@ public ColorConsoleAnnotatorTest() {
public LoggerRule logging = new LoggerRule().record(ColorConsoleAnnotator.class, Level.FINER);

@Test
public void testGlobalPipelineColorMap() throws Exception {
public void testGlobalPipelineColorMap() {
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
Expand All @@ -42,9 +39,9 @@ public void evaluate() throws Throwable {
p.setDefinition(new CpsFlowDefinition(
"echo 'The following word is supposed to be \\u001B[31mred\\u001B[0m'"
, true));
WorkflowRun run = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
StringWriter writer = new StringWriter();
p.getLastBuild().getLogText().writeHtmlTo(0L, writer);
assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
assertTrue("Failed to match color attribute in following HTML log output:\n" + html,
html.replaceAll("<!--.+?-->", "").matches("(?s).*<span style=\"color: #CD0000;\">red</span>.*"));
Expand All @@ -53,7 +50,7 @@ public void evaluate() throws Throwable {
}

@Test
public void testNoGlobalPipelineColorMap() throws Exception {
public void testNoGlobalPipelineColorMap() {
story.addStep(new Statement() {
@Override
public void evaluate() throws Throwable {
Expand All @@ -62,9 +59,9 @@ public void evaluate() throws Throwable {
p.setDefinition(new CpsFlowDefinition(
"echo 'The following word is supposed to be \\u001B[31mred\\u001B[0m'"
, true));
WorkflowRun run = story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
story.j.assertBuildStatusSuccess(p.scheduleBuild2(0));
StringWriter writer = new StringWriter();
p.getLastBuild().getLogText().writeHtmlTo(0L, writer);
assertTrue(p.getLastBuild().getLogText().writeHtmlTo(0L, writer) > 0);
String html = writer.toString();
assertFalse("Color attribute was applied in following HTML log output even though the color map was not globally enabled:\n" + html,
html.replaceAll("<!--.+?-->", "").matches("(?s).*<span style=\"color: #CD0000;\">red</span>.*"));
Expand Down

0 comments on commit 29b8136

Please sign in to comment.