Use build jars in test classpaths by default

-Allows packaged resource files to be accessed within tests

-Guards against packaging errors in dist/ jars by testing the
jars that actually get run rather than unpackaged class files.
Previously we were only protected against packaging errors in the
monolithic jars posted to our website, not the dist/ jars used in
everyday runs.

-"ant fasttest" still uses the unpackaged class files for speed
(don't want to have to rebuild the jars in fasttest). Relies on
dubious methods to get at the resource files that would end up
in the jars.

-Eliminated the stupid separate "test" ivy config. Now we only
invoke ivy ONCE during an ant build that includes tests.
This commit is contained in:
David Roazen 2012-11-28 20:44:09 -05:00
parent add1ab5d0e
commit b06e71cedf
2 changed files with 36 additions and 39 deletions

View File

@ -185,10 +185,7 @@
<include name="**/*.class"/> <include name="**/*.class"/>
</fileset> </fileset>
<patternset id="dependency.mask" includes="*.jar"> <patternset id="dependency.mask" includes="*.jar" />
<exclude name="testng*.jar" />
<exclude name="bcel*.jar" />
</patternset>
<path id="external.dependencies"> <path id="external.dependencies">
<fileset dir="${lib.dir}" erroronmissingdir="false"> <fileset dir="${lib.dir}" erroronmissingdir="false">
@ -205,6 +202,16 @@
<pathelement location="${scala.classes}" /> <pathelement location="${scala.classes}" />
</path> </path>
<path id="build.results">
<!-- Ensure that GenomeAnalysisTK.jar comes first in the path, as it contains overrides for certain classes in our dependencies -->
<pathelement location="${dist.dir}/GenomeAnalysisTK.jar" />
<!-- After GenomeAnalysisTK.jar we include all of the other jars in the dist directory -->
<fileset dir="${dist.dir}" erroronmissingdir="false">
<patternset refid="dependency.mask" />
<exclude name="GenomeAnalysisTK.jar" />
</fileset>
</path>
<fileset id="external.source.files" dir="${external.dir}" erroronmissingdir="false"> <fileset id="external.source.files" dir="${external.dir}" erroronmissingdir="false">
<include name="**/*.java" /> <include name="**/*.java" />
</fileset> </fileset>
@ -240,13 +247,6 @@
</fileset> </fileset>
</path> </path>
<path id="build.results">
<fileset dir="${dist.dir}">
<patternset refid="dependency.mask" />
</fileset>
</path>
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
<!-- Ivy Retrieve --> <!-- Ivy Retrieve -->
<!-- ******************************************************************************** --> <!-- ******************************************************************************** -->
@ -1110,15 +1110,10 @@
</path> </path>
<path id="testng.default.classpath"> <path id="testng.default.classpath">
<pathelement location="${java.classes}" /> <path refid="build.results" />
<pathelement location="${scala.classes}" />
<pathelement location="${java.contracts.dir}" /> <pathelement location="${java.contracts.dir}" />
<pathelement location="${java.test.classes}" /> <pathelement location="${java.test.classes}" />
<pathelement location="${scala.test.classes}" /> <pathelement location="${scala.test.classes}" />
<pathelement location="${R.tar.dir}" />
<path refid="R.script.source.path" />
<pathelement location="${key.dir}" />
<path refid="external.dependencies" />
</path> </path>
<!-- Test targets --> <!-- Test targets -->
@ -1126,9 +1121,6 @@
<target name="test.init.compile"> <target name="test.init.compile">
<mkdir dir="${java.test.classes}"/> <mkdir dir="${java.test.classes}"/>
<mkdir dir="${scala.test.classes}"/> <mkdir dir="${scala.test.classes}"/>
<antcall target="resolve">
<param name="ivy.conf" value="test"/>
</antcall>
</target> </target>
<target name="test.java.internal.compile" depends="dist,test.init.compile"> <target name="test.java.internal.compile" depends="dist,test.init.compile">
@ -1136,10 +1128,8 @@
<javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}"> <javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}">
<src refid="java.test.source.path" /> <src refid="java.test.source.path" />
<classpath> <classpath>
<path refid="external.dependencies" /> <path refid="build.results" />
<pathelement location="${java.classes}"/>
<pathelement location="${java.contracts.dir}"/> <pathelement location="${java.contracts.dir}"/>
<pathelement location="${testng.jar}"/>
</classpath> </classpath>
<compilerarg value="-proc:none"/> <compilerarg value="-proc:none"/>
</javac> </javac>
@ -1150,11 +1140,9 @@
<javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}" srcdir="${external.dir}"> <javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}" srcdir="${external.dir}">
<include name="*/test/**/*.java"/> <include name="*/test/**/*.java"/>
<classpath> <classpath>
<path refid="external.dependencies" /> <path refid="build.results" />
<pathelement location="${java.test.classes}"/> <pathelement location="${java.test.classes}"/>
<pathelement location="${java.classes}"/>
<pathelement location="${java.contracts.dir}"/> <pathelement location="${java.contracts.dir}"/>
<pathelement location="${testng.jar}"/>
</classpath> </classpath>
<compilerarg value="-proc:none"/> <compilerarg value="-proc:none"/>
</javac> </javac>
@ -1167,9 +1155,8 @@
<scalac fork="true" jvmargs="-Xmx512m" destdir="${scala.test.classes}" deprecation="yes" unchecked="yes"> <scalac fork="true" jvmargs="-Xmx512m" destdir="${scala.test.classes}" deprecation="yes" unchecked="yes">
<src refid="scala.test.source.path" /> <src refid="scala.test.source.path" />
<classpath> <classpath>
<path refid="scala.dependencies"/> <path refid="build.results"/>
<pathelement location="${java.test.classes}"/> <pathelement location="${java.test.classes}"/>
<pathelement location="${testng.jar}"/>
</classpath> </classpath>
</scalac> </scalac>
</target> </target>
@ -1376,14 +1363,13 @@
<!-- Fast test target that cuts major corners for speed. Requires that a full build has been done first. Java-only, single test class only --> <!-- Fast test target that cuts major corners for speed. Requires that a full build has been done first. Java-only, single test class only -->
<!-- Usage: ant fasttest -Dsingle=TestClass --> <!-- Usage: ant fasttest -Dsingle=TestClass -->
<target name="fasttest" depends="init.javaonly,init,test.init"> <target name="fasttest" depends="init.javaonly,init">
<condition property="not.clean"> <condition property="not.clean">
<and> <and>
<available file="${build.dir}" /> <available file="${build.dir}" />
<available file="${lib.dir}" /> <available file="${lib.dir}" />
<available file="${dist.dir}" /> <available file="${dist.dir}" />
<available file="${java.test.classes}" /> <available file="${java.test.classes}" />
<available file="${testng.jar}" />
</and> </and>
</condition> </condition>
<fail message="fasttest requires a NON-CLEAN working directory (INCLUDING test classes). Do a full test build using ant test.compile first." unless="not.clean" /> <fail message="fasttest requires a NON-CLEAN working directory (INCLUDING test classes). Do a full test build using ant test.compile first." unless="not.clean" />
@ -1401,13 +1387,27 @@
<javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}"> <javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}">
<src refid="java.test.source.path" /> <src refid="java.test.source.path" />
<classpath> <classpath>
<path refid="external.dependencies" />
<pathelement location="${java.classes}"/> <pathelement location="${java.classes}"/>
<pathelement location="${testng.jar}"/> <path refid="external.dependencies" />
</classpath> </classpath>
<compilerarg value="-proc:none"/> <compilerarg value="-proc:none"/>
</javac> </javac>
<!-- fasttest uses the unpackaged class files in its test classpath to avoid having to rebuild the jars in dist/ -->
<path id="testng.fasttest.classpath">
<pathelement location="${java.classes}" />
<pathelement location="${scala.classes}" />
<pathelement location="${java.contracts.dir}" />
<pathelement location="${java.test.classes}" />
<pathelement location="${scala.test.classes}" />
<pathelement location="${R.tar.dir}" />
<path refid="R.script.source.path" />
<pathelement location="${key.dir}" />
<path refid="external.dependencies" />
<path refid="java.source.path" /> <!-- Terrible hack to allow fasttest to see resource files stored in the source tree -->
</path>
<property name="testng.classpath" value="testng.fasttest.classpath" />
<run-test testtype="${single}" outputdir="${report}/${single}" runfailed="false"/> <run-test testtype="${single}" outputdir="${report}/${single}" runfailed="false"/>
</target> </target>
</project> </project>

11
ivy.xml
View File

@ -24,11 +24,8 @@
<ivy-module version="1.0"> <ivy-module version="1.0">
<info organisation="org.broadinstitute" module="Sting"/> <info organisation="org.broadinstitute" module="Sting"/>
<configurations defaultconfmapping="test->default"> <configurations>
<conf name="default" description="the core dependencies for the GATK"/> <conf name="default" description="the core dependencies for the GATK"/>
<conf name="test" extends="default" description="external dependencies used for testing and metrics"/>
<conf name="scala" extends="default" description="the dependencies for scala"/>
<conf name="queue" extends="scala" description="the dependencies for Queue"/>
</configurations> </configurations>
<dependencies defaultconf="default"> <dependencies defaultconf="default">
<dependency org="net.sf" name="sam" rev="latest.integration"/> <dependency org="net.sf" name="sam" rev="latest.integration"/>
@ -83,9 +80,9 @@
<dependency org="org.scala-lang" name="scala-library" rev="2.9.2"/> <dependency org="org.scala-lang" name="scala-library" rev="2.9.2"/>
<!-- testing and evaluation dependencies --> <!-- testing and evaluation dependencies -->
<dependency org="org.testng" name="testng" rev="5.14.1" conf="test"/> <dependency org="org.testng" name="testng" rev="5.14.1"/>
<dependency org="org.uncommons" name="reportng" rev="1.1.2" conf="test"/> <dependency org="org.uncommons" name="reportng" rev="1.1.2"/>
<dependency org="com.google.code.caliper" name="caliper" rev="1.0-SNAPSHOT" conf="test"/> <dependency org="com.google.code.caliper" name="caliper" rev="1.0-SNAPSHOT"/>
<!-- Contracts for Java and dependencies --> <!-- Contracts for Java and dependencies -->
<dependency org="com.google.code.cofoja" name="cofoja" rev="1.0-r139"/> <dependency org="com.google.code.cofoja" name="cofoja" rev="1.0-r139"/>