1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/apifest1/day3-intermezzo/common.xml Sat Jun 14 09:52:52 2008 +0200
1.3 @@ -0,0 +1,105 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<!-- this is a template file to test -->
1.6 +<project name="common" default="run" basedir=".">
1.7 + <description>Builds the test against first version and runs them against two</description>
1.8 +
1.9 + <loadproperties srcfile="${ant.file.common}/../common.properties"/>
1.10 + <loadproperties srcfile="project.properties"/>
1.11 +
1.12 + <target name="make-sure-projects-are-compiled">
1.13 + <ant dir="${dayA}/${apitotest}" target="compile"/>
1.14 + <ant dir="${dayB}/${apitotest}" target="compile"/>
1.15 + </target>
1.16 +
1.17 + <target name="compile" depends="make-sure-projects-are-compiled">
1.18 + <mkdir dir="build/tests"/>
1.19 + <echo level="info" message="Compiling the tests against old version of the API"/>
1.20 + <javac destdir="build/tests" srcdir="test">
1.21 + <classpath>
1.22 + <pathelement location="${apiA}"/>
1.23 + <pathelement location="${junit.jar}"/>
1.24 + </classpath>
1.25 + </javac>
1.26 + </target>
1.27 +
1.28 + <target name="run" depends="-run-binary-check,-run-source-check">
1.29 + <fail message="The test shall either compile against A and not B or run on A and fail on B, nothing like that happened">
1.30 + <condition>
1.31 + <not><or>
1.32 + <isset property="execution.failed"/>
1.33 + <isset property="compilation.failed"/>
1.34 + </or></not>
1.35 + </condition>
1.36 + </fail>
1.37 + </target>
1.38 +
1.39 + <target name="-run-binary-check" depends="compile">
1.40 + <mkdir dir="build/testresultA"/>
1.41 +
1.42 + <echo level="info" message="Running the tests against old version of the API"/>
1.43 + <junit dir="build/tests" failureproperty="run.on.A.shall.succeed" fork="true">
1.44 + <batchtest todir="build/testresultA">
1.45 + <fileset dir="test" includes="**/*.java"/>
1.46 + </batchtest>
1.47 + <formatter type="brief" usefile="false"/>
1.48 + <formatter type="xml"/>
1.49 + <classpath>
1.50 + <pathelement location="${apiA}"/>
1.51 + <pathelement location="${junit.jar}"/>
1.52 + <pathelement location="build/tests"/>
1.53 + </classpath>
1.54 + </junit>
1.55 +
1.56 + <mkdir dir="build/testresultB"/>
1.57 + <echo level="info" message="Running the same tests against new version of the API, this should fail, if there is binary or functional incompatibility"/>
1.58 + <junit dir="build/tests" failureproperty="run.on.B.shall.fail" fork="true">
1.59 + <batchtest todir="build/testresultB">
1.60 + <fileset dir="test" includes="**/*.java"/>
1.61 + </batchtest>
1.62 + <formatter type="brief" usefile="false"/>
1.63 + <formatter type="xml"/>
1.64 + <classpath>
1.65 + <pathelement location="${apiB}"/>
1.66 + <pathelement location="${junit.jar}"/>
1.67 + <pathelement location="build/tests"/>
1.68 + </classpath>
1.69 + </junit>
1.70 +
1.71 + <condition property="execution.failed">
1.72 + <and>
1.73 + <isset property="run.on.B.shall.fail"/>
1.74 + <not><isset property="run.on.A.shall.succeed"/></not>
1.75 + </and>
1.76 + </condition>
1.77 + </target>
1.78 +
1.79 + <target name="-run-source-check" depends="compile" unless="execution.failed">
1.80 +
1.81 + <property name="build.b" location="build/verifyitbuildsagainstB"/>
1.82 + <delete dir="${build.b}"/>
1.83 + <mkdir dir="${build.b}"/>
1.84 +
1.85 +
1.86 + <echo level="info" message="Verifying source compatibility: Compiling the tests against new version of the API"/>
1.87 + <javac destdir="${build.b}" srcdir="test" failonerror="false" fork="true">
1.88 + <classpath>
1.89 + <pathelement location="${apiB}"/>
1.90 + <pathelement location="${junit.jar}"/>
1.91 + </classpath>
1.92 + </javac>
1.93 +
1.94 +
1.95 + <uptodate property="compilation.failed">
1.96 + <srcfiles dir="${build.b}" includes="**/*.class"/>
1.97 + <mapper type="glob" from="*" to="build/tests/*"/>
1.98 + </uptodate>
1.99 +
1.100 +
1.101 + </target>
1.102 +
1.103 + <target name="test" depends="run"/>
1.104 +
1.105 + <target name="clean">
1.106 + <delete dir="build"/>
1.107 + </target>
1.108 +</project>