awips2/tests/build.xml

134 lines
5.1 KiB
XML
Raw Normal View History

<project name="tests" basedir="." default="run-tests">
<target name="env-check">
<available file="${basedir}/../javax.mail" property="jenkins.build" />
</target>
<target name="env-developer" depends="env-check" unless="jenkins.build">
<property name="build.properties.file" value="developer-build.properties" />
</target>
<target name="env-jenkins" depends="env-check" if="jenkins.build">
<property name="build.properties.file" value="jenkins-build.properties" />
</target>
<target name="env-setup" description="Sets up the environment" depends="env-check, env-developer, env-jenkins">
<property environment="env" />
<property file="${build.properties.file}" />
<property file="build.properties" />
<property file="${BUILD.EDEX.PROPERTIES}" />
<taskdef resource="net/sf/antcontrib/antlib.xml">
<classpath>
<fileset file="${ANT.CONTRIB.JAR}" />
</classpath>
</taskdef>
<delete dir="${WORKING.DIR}" />
</target>
<target name="classpath-setup-developer" depends="env-setup" unless="jenkins.build">
<path id="test.compile.classpath">
<dirset dir="${AWIPS2_BASELINE}" includes="**/bin" />
<fileset dir="${AWIPS2_BASELINE}/cots/org.hamcrest" includes="**/*.jar" />
<fileset dir="${AWIPS2_BASELINE}/cots/org.mockito" includes="**/*.jar" />
<fileset dir="${AWIPS2_BASELINE}/cots/org.springframework" includes="**/*.jar" />
<fileset dir="${AWIPS2_BASELINE}/cots/org.slf4j" includes="**/*.jar" />
<fileset dir="${AWIPS2_BASELINE}/cots" includes="**/*.jar" excludes="**/ant-*.jar" />
<fileset dir="${PROJECTS.DIR}/cots" includes="**/*.jar" />
<dirset dir="${PROJECTS.DIR}" includes="**/bin" />
<fileset dir="${basedir}/lib" includes="**/*.jar" />
</path>
<path id="test.run.classpath">
<!-- Currently nothing else required here -->
</path>
</target>
<target name="classpath-setup-jenkins" depends="env-setup" if="jenkins.build">
<mkdir dir="${UNZIP.DIR}" />
<for param="zipFile">
<path>
<fileset dir="${BUILD.EDEX.DIST.DIR}" includes="*.zip" />
</path>
<sequential>
<unzip dest="${UNZIP.DIR}" src="@{zipFile}" />
</sequential>
</for>
<path id="test.compile.classpath">
<fileset dir="${UNZIP.DIR}" includes="**/*.jar" excludes="**/ant-*.jar" />
<fileset dir="${PROJECTS.DIR}/org.hamcrest" includes="**/*.jar" />
<fileset dir="${PROJECTS.DIR}/org.mockito" includes="**/*.jar" />
<fileset dir="${PROJECTS.DIR}/org.springframework" includes="**/*.jar" />
<fileset dir="${PROJECTS.DIR}/org.slf4j" includes="**/*.jar" />
<fileset dir="${basedir}/lib" includes="**/*.jar" />
</path>
<!-- Include resource files provided by projects -->
<path id="test.run.classpath">
<dirset dir="${PROJECTS.DIR}" includes="*/resources" />
<dirset dir="${PROJECTS.DIR}" includes="*/res" />
</path>
</target>
<target name="classpath-setup" depends="classpath-setup-developer, classpath-setup-jenkins" />
<target name="compile-tests" depends="classpath-setup" description="Compiles all tests">
<delete dir="${TEST.COMPILE.DIR}" />
<mkdir dir="${TEST.COMPILE.DIR}" />
<forEachTestType>
<javac srcdir="${basedir}/@{testType}" excludes="${TEST.EXCLUSION.PATTERN}" destdir="${TEST.COMPILE.DIR}" classpathref="test.compile.classpath" debug="on" source="${javacSource}" target="${javacTarget}" />
</forEachTestType>
</target>
<target name="run-tests" depends="compile-tests" description="Runs all tests">
<delete dir="${TEST.REPORTS.DIR}" />
<mkdir dir="${TEST.REPORTS.DIR}" />
<forEachTestType>
<var name="testTypeSourceDir" value="${basedir}/@{testType}" />
<!-- Test type forking settings -->
<propertycopy name="forkTests" from="@{testType}.FORK.TESTS" override="true" />
<propertycopy name="forkMode" from="@{testType}.FORK.MODE" override="true" />
<propertycopy name="forkCloneVm" from="@{testType}.FORK.CLONEVM" override="true" />
<junit printsummary="yes" forkmode="${forkMode}" clonevm="${forkCloneVm}" haltonfailure="no" failureproperty="tests.failed">
<jvmarg line="-Duser.dir=${testTypeSourceDir} -XX:PermSize=${env.INITIAL_PERMGEN_SIZE} -XX:MaxPermSize=${env.MAX_PERMGEN_SIZE}" />
<classpath>
<!-- Any resources for tests -->
<pathelement location="${testTypeSourceDir}" />
<pathelement location="${basedir}/resources" />
<!-- Referenced jar files -->
<path refid="test.compile.classpath" />
<path refid="test.run.classpath" />
<!-- Compiled tests -->
<pathelement location="${TEST.COMPILE.DIR}" />
</classpath>
<formatter type="xml" />
<batchtest fork="${forkTests}" todir="${TEST.REPORTS.DIR}">
<fileset dir="${basedir}/@{testType}" includes="${TEST.INCLUSION.PATTERN}" excludes="${TEST.EXCLUSION.PATTERN}" />
</batchtest>
</junit>
</forEachTestType>
<fail if="tests.failed" message="Received a FAILED status for one or more test results!" />
</target>
<macrodef name="forEachTestType" description="Loops over all requested test types, and performs the passed in action">
<element name="action" implicit="true" />
<sequential>
<for list="${testTypes}" param="testType">
<sequential>
<action />
</sequential>
</for>
</sequential>
</macrodef>
</project>