From dcb7efcc0e3da57d2a6e0b8ab6f30bc5f027ee11 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Fri, 19 Mar 2021 01:55:01 +0100 Subject: [testing] improve the output of `ant test`. --- buildScripts/tests.ant.xml | 32 ++++++++----- src/support/lombok/ant/SimpleTestFormatter.java | 61 +++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 src/support/lombok/ant/SimpleTestFormatter.java diff --git a/buildScripts/tests.ant.xml b/buildScripts/tests.ant.xml index 961531af..dc0b4147 100644 --- a/buildScripts/tests.ant.xml +++ b/buildScripts/tests.ant.xml @@ -24,6 +24,13 @@ This buildfile is part of projectlombok.org. It takes care of compiling and running tests. + + + + + + + @@ -57,32 +64,33 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn --limit-modules java.base,jdk.unsupported - + Running TestJavac on JVM${ant.java.version}, with lowest supported javac: 1.6. - + + - + Running TestJavac on JVM${ant.java.version}, with javac: 1.8. - + @@ -100,7 +108,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn Running TestJavac with JVM ${jvm.loc.@{version}}. - + @@ -111,18 +119,18 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn - + - + - + Running TestJavac on JVM${ant.java.version}, with the javac built into your VM distributon. - + @@ -140,7 +148,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn - + @@ -151,11 +159,11 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn - + - + diff --git a/src/support/lombok/ant/SimpleTestFormatter.java b/src/support/lombok/ant/SimpleTestFormatter.java new file mode 100644 index 00000000..2f605d06 --- /dev/null +++ b/src/support/lombok/ant/SimpleTestFormatter.java @@ -0,0 +1,61 @@ +package lombok.ant; + +import java.io.OutputStream; +import java.io.PrintStream; + +import junit.framework.AssertionFailedError; +import junit.framework.Test; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter; +import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest; + +public class SimpleTestFormatter implements JUnitResultFormatter { + private PrintStream out = System.out; + + @Override + public void addError(Test test, Throwable error) { + logResult(test, "ERR"); + out.println(error.getMessage()); + } + + @Override + public void addFailure(Test test, AssertionFailedError failure) { + logResult(test, "FAIL"); + out.println(failure.getMessage()); + } + + @Override + public void endTest(Test test) { + logResult(test, "PASS"); + } + + @Override + public void startTest(Test test) { } + + @Override + public void endTestSuite(JUnitTest testSuite) throws BuildException { } + + @Override + public void setOutput(OutputStream out) { + this.out = new PrintStream(out); + } + + @Override + public void setSystemError(String err) { + // don't echo test error output + } + + @Override + public void setSystemOutput(String out) { + // don't echo test output + } + + @Override + public void startTestSuite(JUnitTest testSuite) throws BuildException { } + + private void logResult(Test test, String result) { + out.println("[" + result + "] " + String.valueOf(test)); + out.flush(); + } +} -- cgit