taskx/common.xml
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Sat, 18 Oct 2008 08:40:32 +0200
changeset 74 c2585d97e1e3
parent 14 d907b216f8a1
permissions -rw-r--r--
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>
     5 
     6     <loadproperties srcfile="${ant.file.common}/../common.properties"/>
     7     <loadproperties srcfile="project.properties"/>
     8     
     9     <target name="make-sure-projects-are-compiled">
    10         <ant dir="${taskA}/${apitotest}" target="compile"/>
    11         <ant dir="${taskB}/${apitotest}" target="compile"/>
    12     </target>
    13     
    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">
    18             <classpath>
    19                 <pathelement location="${apiA}"/>
    20                 <pathelement location="${junit.jar}"/>
    21             </classpath>
    22         </javac>
    23     </target>
    24     
    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">
    27             <condition>
    28                 <not><or>
    29                     <isset property="execution.failed"/>
    30                     <isset property="compilation.failed"/>
    31                 </or></not>
    32             </condition>
    33         </fail>
    34         <delete dir="build/testresultA"/>
    35         <delete dir="build/testresultB"/>
    36     </target>
    37         
    38     <target name="-run-binary-check" depends="compile">
    39         <mkdir dir="build/testresultA"/>
    40 
    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"/>
    45             </batchtest>
    46             <formatter type="brief" usefile="false"/>
    47             <formatter type="xml"/>
    48             <classpath>
    49                 <pathelement location="${apiA}"/>
    50                 <pathelement location="${junit.jar}"/>
    51                 <pathelement location="build/tests"/>
    52             </classpath>
    53         </junit>
    54         
    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"/>
    60             </batchtest>
    61             <formatter type="brief" usefile="false"/>
    62             <formatter type="xml"/>
    63             <classpath>
    64                 <pathelement location="${apiB}"/>
    65                 <pathelement location="${junit.jar}"/>
    66                 <pathelement location="build/tests"/>
    67             </classpath>
    68         </junit>
    69         
    70         <condition property="execution.failed">
    71             <and>
    72                 <isset property="run.on.B.shall.fail"/>
    73                 <not><isset property="run.on.A.shall.succeed"/></not>
    74             </and>
    75         </condition>
    76     </target>
    77     
    78     <target name="-run-source-check" depends="compile" unless="execution.failed">
    79         
    80         <property name="build.b" location="build/verifyitbuildsagainstB"/>
    81         <delete dir="${build.b}"/>
    82         <mkdir dir="${build.b}"/>
    83 
    84         
    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">
    87             <classpath>
    88                 <pathelement location="${apiB}"/>
    89                 <pathelement location="${junit.jar}"/>
    90             </classpath>
    91         </javac>
    92 
    93         
    94         <uptodate property="compilation.failed">
    95             <srcfiles dir="${build.b}" includes="**/*.class"/>
    96             <mapper type="glob" from="*" to="build/tests/*"/>
    97         </uptodate>
    98         
    99 
   100     </target>
   101     
   102     <target name="test" depends="run"/>
   103     
   104     <target name="clean">
   105         <delete dir="build"/>
   106     </target>
   107 </project>