We need to remove XML files describing the result of test run in case of successful build (e.g. there was a test failure) as that prevents Hudson from claiming the build is unstable.
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- this is a template file to test -->
3 <project name="common" default="run" basedir=".">
4 <description>Builds the test against first version and runs them against two</description>
6 <loadproperties srcfile="${ant.file.common}/../common.properties"/>
7 <loadproperties srcfile="project.properties"/>
9 <target name="make-sure-projects-are-compiled">
10 <ant dir="${taskA}/${apitotest}" target="compile"/>
11 <ant dir="${taskB}/${apitotest}" target="compile"/>
14 <target name="compile" depends="make-sure-projects-are-compiled">
15 <mkdir dir="build/tests"/>
16 <echo level="info" message="Compiling the tests against old version of the API"/>
17 <javac destdir="build/tests" srcdir="test">
19 <pathelement location="${apiA}"/>
20 <pathelement location="${junit.jar}"/>
25 <target name="run" depends="-run-binary-check,-run-source-check">
26 <fail message="The test shall either compile against A and not B or run on A and fail on B, nothing like that happened">
29 <isset property="execution.failed"/>
30 <isset property="compilation.failed"/>
34 <delete dir="build/testresultA"/>
35 <delete dir="build/testresultB"/>
38 <target name="-run-binary-check" depends="compile">
39 <mkdir dir="build/testresultA"/>
41 <echo level="info" message="Running the tests against old version of the API"/>
42 <junit dir="build/tests" failureproperty="run.on.A.shall.succeed" fork="true">
43 <batchtest todir="build/testresultA">
44 <fileset dir="test" includes="**/*.java"/>
46 <formatter type="brief" usefile="false"/>
47 <formatter type="xml"/>
49 <pathelement location="${apiA}"/>
50 <pathelement location="${junit.jar}"/>
51 <pathelement location="build/tests"/>
55 <mkdir dir="build/testresultB"/>
56 <echo level="info" message="Running the same tests against new version of the API, this should fail, if there is binary or functional incompatibility"/>
57 <junit dir="build/tests" failureproperty="run.on.B.shall.fail" fork="true">
58 <batchtest todir="build/testresultB">
59 <fileset dir="test" includes="**/*.java"/>
61 <formatter type="brief" usefile="false"/>
62 <formatter type="xml"/>
64 <pathelement location="${apiB}"/>
65 <pathelement location="${junit.jar}"/>
66 <pathelement location="build/tests"/>
70 <condition property="execution.failed">
72 <isset property="run.on.B.shall.fail"/>
73 <not><isset property="run.on.A.shall.succeed"/></not>
78 <target name="-run-source-check" depends="compile" unless="execution.failed">
80 <property name="build.b" location="build/verifyitbuildsagainstB"/>
81 <delete dir="${build.b}"/>
82 <mkdir dir="${build.b}"/>
85 <echo level="info" message="Verifying source compatibility: Compiling the tests against new version of the API"/>
86 <javac destdir="${build.b}" srcdir="test" failonerror="false" fork="true">
88 <pathelement location="${apiB}"/>
89 <pathelement location="${junit.jar}"/>
94 <uptodate property="compilation.failed">
95 <srcfiles dir="${build.b}" includes="**/*.class"/>
96 <mapper type="glob" from="*" to="build/tests/*"/>
102 <target name="test" depends="run"/>
104 <target name="clean">
105 <delete dir="build"/>