diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-10-22 09:47:56 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2012-10-22 09:47:56 +0200 |
commit | a295c4fc12247eedfe5747b547d8ac7079f33533 (patch) | |
tree | 3b6e32b547a4877d1f2b0c1a4b0771d0657993a7 /build.xml | |
parent | 0baf73b2aaecebf75a51f3d064c6d925a52f1a6d (diff) | |
download | lombok-a295c4fc12247eedfe5747b547d8ac7079f33533.tar.gz lombok-a295c4fc12247eedfe5747b547d8ac7079f33533.tar.bz2 lombok-a295c4fc12247eedfe5747b547d8ac7079f33533.zip |
Ever since we do a lot more than just calling 'parse' when running delombok in our tests, the tests are in the unfortunate scenario where we always compile against a given javac (lib/build/javac6.jar), and always run the tests against a given javac, but that javac tries to use the bootclasspath of the host JRE, and if that is JRE7, you get all sorts of errors.
I fixed it by still compiling against a given javac (we can only ship one lombok.jar after all), but having the test task run with a given bootclasspath and a given javac.jar.
There are 2 tasks that download both rt.jar and javac.jar for either OpenJDK6 or OpenJDK7, and it writes a properties file with those locations. The test task will use this property file, and explain what you need to do if it is not there.
Incidentally, this brought to light issue 422: Delombok in java7 produces VerifyErrors.
Diffstat (limited to 'build.xml')
-rw-r--r-- | build.xml | 51 |
1 files changed, 49 insertions, 2 deletions
@@ -327,13 +327,60 @@ the common tasks and can be called on to run the main aspects of all the sub-scr </java> </target> - <target name="test" depends="-test-compile, dist, test-ecj" unless="tests.skip" description="Runs the tests."> + <target name="-loadTestEnvironmentProperties"> + <property file="testenvironment.properties" /> + </target> + + <target name="setupJava6TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK6."> + <mkdir dir="lib/openJDK6Environment" /> + <get src="http://projectlombok.org/ivyrepo/langtools/javac-1.6.0.18.jar" dest="lib/openJDK6Environment/javac6.jar" verbose="true" usetimestamp="true" /> + <get src="http://projectlombok.org/ivyrepo/langtools/rt-openjdk6.jar" dest="lib/openJDK6Environment/rt-openjdk6.jar" verbose="true" usetimestamp="true" /> + <propertyfile file="testenvironment.properties"> + <entry key="test.location.javac" value="lib/openJDK6Environment/javac6.jar" /> + <entry key="test.location.bootclasspath" value="lib/openJDK6Environment/rt-openjdk6.jar" /> + </propertyfile> + <echo>Tests will now run against OpenJDK6</echo> + </target> + + <target name="setupJava7TestEnvironment" description="Sets up the test so that 'ant test' will test against OpenJDK7."> + <mkdir dir="lib/openJDK7Environment" /> + <get src="http://projectlombok.org/ivyrepo/langtools/javac-1.7.0.jar" dest="lib/openJDK7Environment/javac7.jar" verbose="true" usetimestamp="true" /> + <get src="http://projectlombok.org/ivyrepo/langtools/rt-openjdk7.jar" dest="lib/openJDK7Environment/rt-openjdk7.jar" verbose="true" usetimestamp="true" /> + <propertyfile file="testenvironment.properties"> + <entry key="test.location.javac" value="lib/openJDK7Environment/javac7.jar" /> + <entry key="test.location.bootclasspath" value="lib/openJDK7Environment/rt-openjdk7.jar" /> + </propertyfile> + <echo>Tests will now run against OpenJDK7</echo> + </target> + + <target name="-failIfNoTestEnvironmentProperties" unless="test.location.javac"> + <fail unless="test.location.javac">ERROR: No test environment set up. + +You need to set up a test environment, which consists of a version of javac, and a JRE runtime classpath ('rt.jar'). +Eventually, this environment concept will be extended to also includes an ecj and/or eclipse to test against. + +You can let this ant script set them up for you: + +* ant setupJava6TestEnvironment +* ant setupJava7TestEnvironment + +These will set up test environments based on OpenJDK6 and OpenJDK7 and some recent version of eclipse, and download all required files automatically. This will be a relatively large download. You can switch by running this command again; the downloads are cached so switching is fast. + +You can also create your own by writing a 'testenvironment.properties' file. The relevant properties are: + +* test.location.javac = /path/to/javac6.jar +* test.location.bootclasspath = /path/to/rt.jar +</fail> + </target> + + <target name="test" depends="-loadTestEnvironmentProperties, -failIfNoTestEnvironmentProperties, -test-compile, dist, test-ecj" unless="tests.skip" description="Runs the tests."> <junit haltonfailure="yes" fork="true"> <jvmarg value="-javaagent:dist/lombok.jar" /> + <jvmarg value="-Ddelombok.bootclasspath=${test.location.bootclasspath}" /> <formatter type="plain" usefile="false" unless="tests.quiet" /> <classpath refid="test.path" /> <classpath refid="eclipseBuild.path" /> - <classpath path="lib/javac6/javac6.jar" /> + <classpath path="${test.location.javac}" /> <classpath path="build/lombok" /> <classpath path="build/tests" /> <batchtest> |