aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--buildScripts/ivy.xml2
-rw-r--r--buildScripts/tests.ant.xml39
-rw-r--r--src/ant/lombok/ant/SimpleTestFormatter.java122
-rw-r--r--test/core/src/lombok/RunTestsViaEcj.java11
-rw-r--r--test/stubs/java/lang/Record.java3
-rw-r--r--test/stubs/java/lang/runtime/ObjectMethods.java12
6 files changed, 134 insertions, 55 deletions
diff --git a/buildScripts/ivy.xml b/buildScripts/ivy.xml
index da46ab91..0da5c3fc 100644
--- a/buildScripts/ivy.xml
+++ b/buildScripts/ivy.xml
@@ -28,6 +28,7 @@
<conf name="ecj8" />
<conf name="ecj11" />
<conf name="ecj14" />
+ <conf name="ecj16" />
<conf name="eclipse-oxygen" />
<conf name="eclipse-202006" />
@@ -76,6 +77,7 @@
<!-- ecjs -->
+ <dependency org="org.eclipse.jdt" name="ecj" rev="3.25.0" conf="ecj16->master" />
<dependency org="org.eclipse.jdt" name="ecj" rev="3.22.0.v20200530-2032" conf="ecj14->master" />
<dependency org="org.eclipse.jdt" name="ecj" rev="3.16.0" conf="ecj11->master" />
<!-- until oct 2016, ecj was released under org 'org.eclipse.jdt.core.compiler', and the versioning followed eclipse's versions. -->
diff --git a/buildScripts/tests.ant.xml b/buildScripts/tests.ant.xml
index 4cd36b9e..9d9e9541 100644
--- a/buildScripts/tests.ant.xml
+++ b/buildScripts/tests.ant.xml
@@ -55,7 +55,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
</ivy:compile>
</target>
- <target name="test.ecj11" depends="deps, dist" description="Runs a few ecj-specific tests" unless="skip.tests">
+ <target name="test.ecj11.call" depends="deps, dist" description="Runs a few ecj-specific tests" unless="skip.tests">
<java jar="lib/ecj11/org.eclipse.jdt-ecj.jar" fork="true" failonerror="true">
<jvmarg value="-javaagent:dist/lombok.jar=ecj" />
<arg line="-source 1.6 -target 1.6 -cp dist/lombok.jar test/ecj/SimpleTest.java" />
@@ -165,6 +165,7 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<classpath refid="cp.eclipse-@{version}" />
<classpath refid="packing.basedirs.path" />
<classpath location="build/tests" />
+ <classpath location="build/teststubs" />
<test name="lombok.TestEclipse" />
</junit>
</sequential>
@@ -179,6 +180,42 @@ This buildfile is part of projectlombok.org. It takes care of compiling and runn
<test.eclipse-X version="202006" />
</target>
+ <macrodef name="test.ecj-X">
+ <attribute name="version" />
+ <sequential>
+ <echo>Running TestEclipse on ecj-@{version} on JVM${ant.java.version}.</echo>
+ <junit haltonfailure="yes" fork="true" forkmode="once">
+ <formatter classname="lombok.ant.SimpleTestFormatter" usefile="false" unless="tests.quiet" />
+ <jvmarg value="-Xbootclasspath/a:${jdk8-rt.loc}" />
+ <jvmarg value="-Ddelombok.bootclasspath=${jdk8-rt.loc}" />
+ <jvmarg value="-javaagent:dist/lombok.jar" />
+ <classpath location="build/ant" />
+ <classpath refid="cp.test" />
+ <classpath refid="cp.stripe" />
+ <classpath refid="cp.ecj@{version}" />
+ <classpath refid="packing.basedirs.path" />
+ <classpath location="build/tests" />
+ <classpath location="build/teststubs" />
+ <test name="lombok.TestEclipse" />
+ </junit>
+ </sequential>
+ </macrodef>
+
+ <target name="test.ecj11" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj11 release">
+ <fetchdep.ecj version="11" />
+ <test.ecj-X version="11" />
+ </target>
+
+ <target name="test.ecj14" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj11 release">
+ <fetchdep.ecj version="14" />
+ <test.ecj-X version="14" />
+ </target>
+
+ <target name="test.ecj16" depends="test.formatter.compile, test.compile" description="runs the tests on your default VM, testing the ecj11 release">
+ <fetchdep.ecj version="16" />
+ <test.ecj-X version="16" />
+ </target>
+
<target name="test" depends="test.javacCurrent, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" />
<target name="test.broad" depends="test.javac8, test.javac14, test.eclipse-oxygen, test.eclipse-202006" description="runs the tests against the default JVM, javac, and eclipse" />
</project>
diff --git a/src/ant/lombok/ant/SimpleTestFormatter.java b/src/ant/lombok/ant/SimpleTestFormatter.java
index a2a38420..e137d822 100644
--- a/src/ant/lombok/ant/SimpleTestFormatter.java
+++ b/src/ant/lombok/ant/SimpleTestFormatter.java
@@ -2,6 +2,7 @@ package lombok.ant;
import java.io.OutputStream;
import java.io.PrintStream;
+import java.util.Arrays;
import junit.framework.AssertionFailedError;
import junit.framework.Test;
@@ -11,53 +12,76 @@ 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 msg) {
- if (msg.trim().isEmpty()) return;
- out.println(msg);
- }
-
- @Override
- public void setSystemOutput(String msg) {
- if (msg.trim().isEmpty()) return;
- out.println(msg);
- }
-
- @Override
- public void startTestSuite(JUnitTest testSuite) throws BuildException { }
-
- private void logResult(Test test, String result) {
- out.println("[" + result + "] " + String.valueOf(test));
- out.flush();
- }
+ private PrintStream out = System.out;
+ private Test lastMarked = null;
+
+ @Override
+ public void addError(Test test, Throwable error) {
+ lastMarked = test;
+ logResult(test, "ERR");
+ printThrowable(error, false, 2);
+ }
+
+ private void printThrowable(Throwable throwable, boolean cause, int indent) {
+ String msg = throwable.getMessage();
+ char[] prefixChars = new char[indent];
+ Arrays.fill(prefixChars, ' ');
+ String prefix = new String(prefixChars);
+
+ if (msg == null || msg.isEmpty()) {
+ out.println(prefix + (cause ? "Caused by " : "") + throwable.getClass());
+ } else {
+ out.println(prefix + (cause ? "Caused by " : "") + throwable.getClass() + ": " + msg);
+ }
+ StackTraceElement[] elems = throwable.getStackTrace();
+ if (elems != null) for (StackTraceElement elem : elems) {
+ out.println(prefix + " " + elem);
+ }
+
+ Throwable c = throwable.getCause();
+ if (c != null) printThrowable(c, true, indent + 2);
+ }
+
+ @Override
+ public void addFailure(Test test, AssertionFailedError failure) {
+ lastMarked = test;
+ logResult(test, "FAIL");
+ out.println(failure.getMessage());
+ }
+
+ @Override
+ public void endTest(Test test) {
+ if (test != lastMarked) 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 msg) {
+ if (msg.trim().isEmpty()) return;
+ out.println(msg);
+ }
+
+ @Override
+ public void setSystemOutput(String msg) {
+ if (msg.trim().isEmpty()) return;
+ out.println(msg);
+ }
+
+ @Override
+ public void startTestSuite(JUnitTest testSuite) throws BuildException { }
+
+ private void logResult(Test test, String result) {
+ out.println("[" + result + "] " + String.valueOf(test));
+ out.flush();
+ }
}
diff --git a/test/core/src/lombok/RunTestsViaEcj.java b/test/core/src/lombok/RunTestsViaEcj.java
index 1c2be160..2e89f99b 100644
--- a/test/core/src/lombok/RunTestsViaEcj.java
+++ b/test/core/src/lombok/RunTestsViaEcj.java
@@ -110,6 +110,11 @@ public class RunTestsViaEcj extends AbstractRunTests {
};
}
+ private ICompilationUnit getSourceUnit(File file, String source) {
+ if (eclipseAvailable()) return new TestCompilationUnitEclipse(file.getName(), source);
+ return new TestCompilationUnitEcj(file.getName(), source);
+ }
+
@Override
public boolean transformCode(Collection<CompilerMessage> messages, StringWriter result, File file, String encoding, Map<String, String> formatPreferences, int minVersion, boolean checkPositions) throws Throwable {
final AtomicReference<CompilationResult> compilationResult_ = new AtomicReference<CompilationResult>();
@@ -124,11 +129,7 @@ public class RunTestsViaEcj extends AbstractRunTests {
char[] sourceArray = source.toCharArray();
final ICompilationUnit sourceUnit;
try {
- if (eclipseAvailable()) {
- sourceUnit = new TestCompilationUnitEclipse(file.getName(), source);
- } else {
- sourceUnit = new TestCompilationUnitEcj(file.getName(), source);
- }
+ sourceUnit = getSourceUnit(file, source);
} catch (Throwable t) {
t.printStackTrace();
return false;
diff --git a/test/stubs/java/lang/Record.java b/test/stubs/java/lang/Record.java
new file mode 100644
index 00000000..e985bb45
--- /dev/null
+++ b/test/stubs/java/lang/Record.java
@@ -0,0 +1,3 @@
+package java.lang;
+
+public abstract class Record {}
diff --git a/test/stubs/java/lang/runtime/ObjectMethods.java b/test/stubs/java/lang/runtime/ObjectMethods.java
new file mode 100644
index 00000000..519563ae
--- /dev/null
+++ b/test/stubs/java/lang/runtime/ObjectMethods.java
@@ -0,0 +1,12 @@
+package java.lang.runtime;
+
+// import java.lang.invoke.MethodHandle;
+// import java.lang.invoke.MethodHandles;
+// import java.lang.invoke.TypeDescriptor;
+
+public class ObjectMethods {
+// public static Object bootstrap(MethodHandles.Lookup lookup, String methodName, TypeDescriptor type, Class<?> recordClass, String names, MethodHandle... getters) throws Throwable {
+ public static Object bootstrap(Object lookup, String methodName, Object type, Class<?> recordClass, String names, Object... getters) throws Throwable {
+ return null;
+ }
+}