samples/apifest1/day3-intermezzo/jtulach/against-stackbasedsolution/build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:52:49 +0200
changeset 55 5a0b7b1f8f11
parent 54 45b0d58e66ca
child 58 be49ca0fff33
permissions -rw-r--r--
Making jtulach's projects compilable
     1 <?xml version="1.0" encoding="UTF-8"?>
     2 <!-- this is a template file to test  -->
     3 <project name="testing-template" default="run" basedir=".">
     4     <description>Builds the test against first version and runs them against two</description>
     5     
     6     <loadproperties srcfile="project.properties"/>
     7     
     8     <target name="make-sure-projects-are-compiled">
     9         <ant dir="${dayA}/${apitotest}" target="compile"/>
    10         <ant dir="${dayB}/${apitotest}" target="compile"/>
    11     </target>
    12     
    13     <target name="compile" depends="make-sure-projects-are-compiled">
    14         <mkdir dir="build/tests"/>
    15         <echo level="info" message="Compiling the tests against old version of the API"/>
    16         <javac destdir="build/tests" srcdir="test">
    17             <classpath>
    18                 <pathelement location="${apiA}"/>
    19                 <pathelement location="${junit.jar}"/>
    20             </classpath>
    21         </javac>
    22     </target>
    23     
    24     <target name="run" depends="-run-binary-check,-run-source-check">
    25         <fail message="The test shall either compile against A and not B or run on A and fail on B, nothing like that happened">
    26             <condition>
    27                 <not><or>
    28                     <isset property="execution.failed"/>
    29                     <isset property="compilation.failed"/>
    30                 </or></not>
    31             </condition>
    32         </fail>
    33     </target>
    34         
    35     <target name="-run-binary-check" depends="compile">
    36         <mkdir dir="build/testresultA"/>
    37 
    38         <echo level="info" message="Running the tests against old version of the API"/>
    39         <junit dir="build/tests" failureproperty="run.on.A.shall.succeed" fork="true">
    40             <batchtest todir="build/testresultA">
    41                 <fileset dir="test" includes="**/*.java"/>
    42             </batchtest>
    43             <formatter type="brief" usefile="false"/>
    44             <formatter type="xml"/>
    45             <classpath>
    46                 <pathelement location="${apiA}"/>
    47                 <pathelement location="${junit.jar}"/>
    48                 <pathelement location="build/tests"/>
    49             </classpath>
    50         </junit>
    51         
    52         <mkdir dir="build/testresultB"/>
    53         <echo level="info" message="Running the same tests against new version of the API, this should fail, if there is binary or functional incompatibility"/>
    54         <junit dir="build/tests" failureproperty="run.on.B.shall.fail" fork="true">
    55             <batchtest todir="build/testresultB">
    56                 <fileset dir="test" includes="**/*.java"/>
    57             </batchtest>
    58             <formatter type="brief" usefile="false"/>
    59             <formatter type="xml"/>
    60             <classpath>
    61                 <pathelement location="${apiB}"/>
    62                 <pathelement location="${junit.jar}"/>
    63                 <pathelement location="build/tests"/>
    64             </classpath>
    65         </junit>
    66         
    67         <condition property="execution.failed">
    68             <and>
    69                 <isset property="run.on.B.shall.fail"/>
    70                 <not><isset property="run.on.A.shall.succeed"/></not>
    71             </and>
    72         </condition>
    73     </target>
    74     
    75     <target name="-run-source-check" depends="compile" unless="execution.failed">
    76         
    77         <property name="build.b" location="build/verifyitbuildsagainstB"/>
    78         <delete dir="${build.b}"/>
    79         <mkdir dir="${build.b}"/>
    80 
    81         
    82         <echo level="info" message="Verifying source compatibility: Compiling the tests against new version of the API"/>
    83         <javac destdir="${build.b}" srcdir="test" failonerror="false" fork="true">
    84             <classpath>
    85                 <pathelement location="${apiB}"/>
    86                 <pathelement location="${junit.jar}"/>
    87             </classpath>
    88         </javac>
    89 
    90         
    91         <uptodate property="compilation.failed">
    92             <srcfiles dir="${build.b}" includes="**/*.class"/>
    93             <mapper type="glob" from="*" to="build/tests/*"/>
    94         </uptodate>
    95         
    96 
    97     </target>
    98     
    99     <target name="test" depends="run"/>
   100     
   101     <target name="clean">
   102         <delete dir="build"/>
   103     </target>
   104 </project>