Skip to content
Browse files

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.
  • Loading branch information...
1 parent 9a3c6ca commit ca6c025afe4bd48ae02c01bd4127974481bd8c0c @droazen droazen committed Nov 28, 2012
Showing with 36 additions and 39 deletions.
  1. +32 −32 build.xml
  2. +4 −7 ivy.xml
View
64 build.xml
@@ -185,10 +185,7 @@
<include name="**/*.class"/>
</fileset>
- <patternset id="dependency.mask" includes="*.jar">
- <exclude name="testng*.jar" />
- <exclude name="bcel*.jar" />
- </patternset>
+ <patternset id="dependency.mask" includes="*.jar" />
<path id="external.dependencies">
<fileset dir="${lib.dir}" erroronmissingdir="false">
@@ -205,6 +202,16 @@
<pathelement location="${scala.classes}" />
</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">
<include name="**/*.java" />
</fileset>
@@ -240,13 +247,6 @@
</fileset>
</path>
- <path id="build.results">
- <fileset dir="${dist.dir}">
- <patternset refid="dependency.mask" />
- </fileset>
- </path>
-
-
<!-- ******************************************************************************** -->
<!-- Ivy Retrieve -->
<!-- ******************************************************************************** -->
@@ -1110,36 +1110,26 @@
</path>
<path id="testng.default.classpath">
- <pathelement location="${java.classes}" />
- <pathelement location="${scala.classes}" />
+ <path refid="build.results" />
<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>
<!-- Test targets -->
<target name="test.init.compile">
<mkdir dir="${java.test.classes}"/>
<mkdir dir="${scala.test.classes}"/>
- <antcall target="resolve">
- <param name="ivy.conf" value="test"/>
- </antcall>
</target>
<target name="test.java.internal.compile" depends="dist,test.init.compile">
<echo message="Sting: Compiling java test cases!"/>
<javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}">
<src refid="java.test.source.path" />
<classpath>
- <path refid="external.dependencies" />
- <pathelement location="${java.classes}"/>
+ <path refid="build.results" />
<pathelement location="${java.contracts.dir}"/>
- <pathelement location="${testng.jar}"/>
</classpath>
<compilerarg value="-proc:none"/>
</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}">
<include name="*/test/**/*.java"/>
<classpath>
- <path refid="external.dependencies" />
+ <path refid="build.results" />
<pathelement location="${java.test.classes}"/>
- <pathelement location="${java.classes}"/>
<pathelement location="${java.contracts.dir}"/>
- <pathelement location="${testng.jar}"/>
</classpath>
<compilerarg value="-proc:none"/>
</javac>
@@ -1167,9 +1155,8 @@
<scalac fork="true" jvmargs="-Xmx512m" destdir="${scala.test.classes}" deprecation="yes" unchecked="yes">
<src refid="scala.test.source.path" />
<classpath>
- <path refid="scala.dependencies"/>
+ <path refid="build.results"/>
<pathelement location="${java.test.classes}"/>
- <pathelement location="${testng.jar}"/>
</classpath>
</scalac>
</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 -->
<!-- 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">
<and>
<available file="${build.dir}" />
<available file="${lib.dir}" />
<available file="${dist.dir}" />
<available file="${java.test.classes}" />
- <available file="${testng.jar}" />
</and>
</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" />
@@ -1401,13 +1387,27 @@
<javac fork="true" memoryMaximumSize="512m" destdir="${java.test.classes}" debug="true" optimize="on" tempdir="${java.io.tmpdir}">
<src refid="java.test.source.path" />
<classpath>
- <path refid="external.dependencies" />
<pathelement location="${java.classes}"/>
- <pathelement location="${testng.jar}"/>
+ <path refid="external.dependencies" />
</classpath>
<compilerarg value="-proc:none"/>
</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"/>
</target>
</project>
View
11 ivy.xml
@@ -24,11 +24,8 @@
<ivy-module version="1.0">
<info organisation="org.broadinstitute" module="Sting"/>
- <configurations defaultconfmapping="test->default">
+ <configurations>
<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>
<dependencies defaultconf="default">
<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"/>
<!-- testing and evaluation dependencies -->
- <dependency org="org.testng" name="testng" rev="5.14.1" conf="test"/>
- <dependency org="org.uncommons" name="reportng" rev="1.1.2" conf="test"/>
- <dependency org="com.google.code.caliper" name="caliper" rev="1.0-SNAPSHOT" conf="test"/>
+ <dependency org="org.testng" name="testng" rev="5.14.1"/>
+ <dependency org="org.uncommons" name="reportng" rev="1.1.2"/>
+ <dependency org="com.google.code.caliper" name="caliper" rev="1.0-SNAPSHOT"/>
<!-- Contracts for Java and dependencies -->
<dependency org="com.google.code.cofoja" name="cofoja" rev="1.0-r139"/>

0 comments on commit ca6c025

Please sign in to comment.
Something went wrong with that request. Please try again.