taskx/common.xml
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Mon, 29 Sep 2008 06:31:19 +0200
changeset 14 d907b216f8a1
child 74 c2585d97e1e3
permissions -rw-r--r--
Base for the taskx - the verification infrastructure
     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     </target>
    35         
    36     <target name="-run-binary-check" depends="compile">
    37         <mkdir dir="build/testresultA"/>
    38 
    39         <echo level="info" message="Running the tests against old version of the API"/>
    40         <junit dir="build/tests" failureproperty="run.on.A.shall.succeed" fork="true">
    41             <batchtest todir="build/testresultA">
    42                 <fileset dir="test" includes="**/*.java"/>
    43             </batchtest>
    44             <formatter type="brief" usefile="false"/>
    45             <formatter type="xml"/>
    46             <classpath>
    47                 <pathelement location="${apiA}"/>
    48                 <pathelement location="${junit.jar}"/>
    49                 <pathelement location="build/tests"/>
    50             </classpath>
    51         </junit>
    52         
    53         <mkdir dir="build/testresultB"/>
    54         <echo level="info" message="Running the same tests against new version of the API, this should fail, if there is binary or functional incompatibility"/>
    55         <junit dir="build/tests" failureproperty="run.on.B.shall.fail" fork="true">
    56             <batchtest todir="build/testresultB">
    57                 <fileset dir="test" includes="**/*.java"/>
    58             </batchtest>
    59             <formatter type="brief" usefile="false"/>
    60             <formatter type="xml"/>
    61             <classpath>
    62                 <pathelement location="${apiB}"/>
    63                 <pathelement location="${junit.jar}"/>
    64                 <pathelement location="build/tests"/>
    65             </classpath>
    66         </junit>
    67         
    68         <condition property="execution.failed">
    69             <and>
    70                 <isset property="run.on.B.shall.fail"/>
    71                 <not><isset property="run.on.A.shall.succeed"/></not>
    72             </and>
    73         </condition>
    74     </target>
    75     
    76     <target name="-run-source-check" depends="compile" unless="execution.failed">
    77         
    78         <property name="build.b" location="build/verifyitbuildsagainstB"/>
    79         <delete dir="${build.b}"/>
    80         <mkdir dir="${build.b}"/>
    81 
    82         
    83         <echo level="info" message="Verifying source compatibility: Compiling the tests against new version of the API"/>
    84         <javac destdir="${build.b}" srcdir="test" failonerror="false" fork="true">
    85             <classpath>
    86                 <pathelement location="${apiB}"/>
    87                 <pathelement location="${junit.jar}"/>
    88             </classpath>
    89         </javac>
    90 
    91         
    92         <uptodate property="compilation.failed">
    93             <srcfiles dir="${build.b}" includes="**/*.class"/>
    94             <mapper type="glob" from="*" to="build/tests/*"/>
    95         </uptodate>
    96         
    97 
    98     </target>
    99     
   100     <target name="test" depends="run"/>
   101     
   102     <target name="clean">
   103         <delete dir="build"/>
   104     </target>
   105 </project>