diff options
-rw-r--r-- | buildScripts/tests.ant.xml | 32 | ||||
-rw-r--r-- | src/support/lombok/ant/SimpleTestFormatter.java | 61 |
2 files changed, 81 insertions, 12 deletions
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. </description> + <target name="test.formatter.compile" depends="deps"> + <mkdir dir="build/ant" /> + <javac includeantruntime="true" srcdir="src/support" includes="**/SimpleTestFormatter.java" destdir="build/ant"> + <classpath refid="cp.test" /> + </javac> + </target> + <target name="test.compile" depends="deps, compile" description="compiles the tests" unless="skip.tests"> <mkdir dir="build/tests" /> <ivy:compile destdir="build/teststubs" source="1.6" target="1.6" ecj="true" nowarn="true"> @@ -57,32 +64,33 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <property name="test.limitmodules">--limit-modules java.base,jdk.unsupported</property> - <target name="test.javac6" depends="test.compile" description="runs the tests on your default VM, using javac6 as underlying compiler"> + <target name="test.javac6" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac6 as underlying compiler"> <echo>Running TestJavac on JVM${ant.java.version}, with lowest supported javac: 1.6.</echo> <junit haltonfailure="yes" fork="true" forkmode="once"> <jvmarg value="-Xbootclasspath/a:${jdk6-rt.loc}" /> <jvmarg line="${test.limitmodules}" /> <jvmarg value="-Ddelombok.bootclasspath=${jdk6-rt.loc}" /> <jvmarg value="-Dsun.boot.class.path=${jdk6-rt.loc}" /> - <formatter type="plain" usefile="false" unless="tests.quiet" /> + <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" /> <classpath refid="cp.test" /> <classpath refid="cp.stripe" /> <classpath refid="cp.javac6" /> <classpath refid="packing.basedirs.path" /> + <classpath location="build/ant" /> <classpath location="build/tests" /> <classpath location="build/teststubs" /> <test name="lombok.TestJavac" /> </junit> </target> - <target name="test.javac8" depends="test.compile, deps.jdk8-runtime" description="runs the tests on your default VM, using javac8 as underlying compiler"> + <target name="test.javac8" depends="test.formatter.compile, test.compile, deps.jdk8-runtime" description="runs the tests on your default VM, using javac8 as underlying compiler"> <echo>Running TestJavac on JVM${ant.java.version}, with javac: 1.8.</echo> <junit haltonfailure="yes" fork="true" forkmode="once"> <jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" /> <jvmarg line="${test.limitmodules}" /> <jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" /> <jvmarg value="-Dsun.boot.class.path=${jdk8-rt.loc}" /> - <formatter type="plain" usefile="false" unless="tests.quiet" /> + <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" /> <classpath refid="cp.test" /> <classpath refid="cp.stripe" /> <classpath refid="cp.javac8" /> @@ -100,7 +108,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <echo>Running TestJavac with JVM ${jvm.loc.@{version}}.</echo> <junit haltonfailure="yes" fork="true" forkmode="once" jvm="${jvm.loc.@{version}}/bin/${exe.java}"> - <formatter type="plain" usefile="false" unless="tests.quiet" /> + <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" /> <classpath refid="cp.test" /> <classpath refid="cp.stripe" /> <classpath refid="packing.basedirs.path" /> @@ -111,18 +119,18 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn </sequential> </macrodef> - <target name="test.javac11" depends="test.compile" description="runs the tests on your default VM, using javac11 as underlying compiler"> + <target name="test.javac11" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac11 as underlying compiler"> <test.javacX version="11" /> </target> - <target name="test.javac14" depends="test.compile" description="runs the tests on your default VM, using javac14 as underlying compiler"> + <target name="test.javac14" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using javac14 as underlying compiler"> <test.javacX version="14" /> </target> - <target name="test.javacCurrent" depends="test.compile" description="runs the tests on your default VM, using its javac as underlying compiler"> + <target name="test.javacCurrent" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, using its javac as underlying compiler"> <echo>Running TestJavac on JVM${ant.java.version}, with the javac built into your VM distributon.</echo> <junit haltonfailure="yes" fork="true" forkmode="once"> - <formatter type="plain" usefile="false" unless="tests.quiet" /> + <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" /> <classpath refid="cp.test" /> <classpath refid="cp.stripe" /> <classpath refid="packing.basedirs.path" /> @@ -140,7 +148,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn <jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" /> <jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" /> <jvmarg value="-javaagent:dist/lombok.jar" /> - <formatter type="plain" usefile="false" unless="tests.quiet" /> + <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" /> <classpath refid="cp.test" /> <classpath refid="cp.stripe" /> <classpath refid="cp.eclipse-@{version}" /> @@ -151,11 +159,11 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn </sequential> </macrodef> - <target name="test.eclipse-oxygen" depends="test.compile" description="runs the tests on your default VM, testing the oxygen release of eclipse"> + <target name="test.eclipse-oxygen" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the oxygen release of eclipse"> <test.eclipse-X version="oxygen" /> </target> - <target name="test.eclipse-202006" depends="test.compile" description="runs the tests on your default VM, testing the 2020-03 release of eclipse"> + <target name="test.eclipse-202006" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the 2020-03 release of eclipse"> <fetchdep.eclipse version="202006" /> <test.eclipse-X version="202006" /> </target> 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(); + } +} |