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.
jaroslav@14
     1
<?xml version="1.0" encoding="UTF-8"?>
jaroslav@14
     2
<!-- this is a template file to test  -->
jaroslav@14
     3
<project name="common" default="run" basedir=".">
jaroslav@14
     4
    <description>Builds the test against first version and runs them against two</description>
jaroslav@14
     5
jaroslav@14
     6
    <loadproperties srcfile="${ant.file.common}/../common.properties"/>
jaroslav@14
     7
    <loadproperties srcfile="project.properties"/>
jaroslav@14
     8
    
jaroslav@14
     9
    <target name="make-sure-projects-are-compiled">
jaroslav@14
    10
        <ant dir="${taskA}/${apitotest}" target="compile"/>
jaroslav@14
    11
        <ant dir="${taskB}/${apitotest}" target="compile"/>
jaroslav@14
    12
    </target>
jaroslav@14
    13
    
jaroslav@14
    14
    <target name="compile" depends="make-sure-projects-are-compiled">
jaroslav@14
    15
        <mkdir dir="build/tests"/>
jaroslav@14
    16
        <echo level="info" message="Compiling the tests against old version of the API"/>
jaroslav@14
    17
        <javac destdir="build/tests" srcdir="test">
jaroslav@14
    18
            <classpath>
jaroslav@14
    19
                <pathelement location="${apiA}"/>
jaroslav@14
    20
                <pathelement location="${junit.jar}"/>
jaroslav@14
    21
            </classpath>
jaroslav@14
    22
        </javac>
jaroslav@14
    23
    </target>
jaroslav@14
    24
    
jaroslav@14
    25
    <target name="run" depends="-run-binary-check,-run-source-check">
jaroslav@14
    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">
jaroslav@14
    27
            <condition>
jaroslav@14
    28
                <not><or>
jaroslav@14
    29
                    <isset property="execution.failed"/>
jaroslav@14
    30
                    <isset property="compilation.failed"/>
jaroslav@14
    31
                </or></not>
jaroslav@14
    32
            </condition>
jaroslav@14
    33
        </fail>
jaroslav@74
    34
        <delete dir="build/testresultA"/>
jaroslav@74
    35
        <delete dir="build/testresultB"/>
jaroslav@14
    36
    </target>
jaroslav@14
    37
        
jaroslav@14
    38
    <target name="-run-binary-check" depends="compile">
jaroslav@14
    39
        <mkdir dir="build/testresultA"/>
jaroslav@14
    40
jaroslav@14
    41
        <echo level="info" message="Running the tests against old version of the API"/>
jaroslav@14
    42
        <junit dir="build/tests" failureproperty="run.on.A.shall.succeed" fork="true">
jaroslav@14
    43
            <batchtest todir="build/testresultA">
jaroslav@14
    44
                <fileset dir="test" includes="**/*.java"/>
jaroslav@14
    45
            </batchtest>
jaroslav@14
    46
            <formatter type="brief" usefile="false"/>
jaroslav@14
    47
            <formatter type="xml"/>
jaroslav@14
    48
            <classpath>
jaroslav@14
    49
                <pathelement location="${apiA}"/>
jaroslav@14
    50
                <pathelement location="${junit.jar}"/>
jaroslav@14
    51
                <pathelement location="build/tests"/>
jaroslav@14
    52
            </classpath>
jaroslav@14
    53
        </junit>
jaroslav@14
    54
        
jaroslav@14
    55
        <mkdir dir="build/testresultB"/>
jaroslav@14
    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"/>
jaroslav@14
    57
        <junit dir="build/tests" failureproperty="run.on.B.shall.fail" fork="true">
jaroslav@14
    58
            <batchtest todir="build/testresultB">
jaroslav@14
    59
                <fileset dir="test" includes="**/*.java"/>
jaroslav@14
    60
            </batchtest>
jaroslav@14
    61
            <formatter type="brief" usefile="false"/>
jaroslav@14
    62
            <formatter type="xml"/>
jaroslav@14
    63
            <classpath>
jaroslav@14
    64
                <pathelement location="${apiB}"/>
jaroslav@14
    65
                <pathelement location="${junit.jar}"/>
jaroslav@14
    66
                <pathelement location="build/tests"/>
jaroslav@14
    67
            </classpath>
jaroslav@14
    68
        </junit>
jaroslav@14
    69
        
jaroslav@14
    70
        <condition property="execution.failed">
jaroslav@14
    71
            <and>
jaroslav@14
    72
                <isset property="run.on.B.shall.fail"/>
jaroslav@14
    73
                <not><isset property="run.on.A.shall.succeed"/></not>
jaroslav@14
    74
            </and>
jaroslav@14
    75
        </condition>
jaroslav@14
    76
    </target>
jaroslav@14
    77
    
jaroslav@14
    78
    <target name="-run-source-check" depends="compile" unless="execution.failed">
jaroslav@14
    79
        
jaroslav@14
    80
        <property name="build.b" location="build/verifyitbuildsagainstB"/>
jaroslav@14
    81
        <delete dir="${build.b}"/>
jaroslav@14
    82
        <mkdir dir="${build.b}"/>
jaroslav@14
    83
jaroslav@14
    84
        
jaroslav@14
    85
        <echo level="info" message="Verifying source compatibility: Compiling the tests against new version of the API"/>
jaroslav@14
    86
        <javac destdir="${build.b}" srcdir="test" failonerror="false" fork="true">
jaroslav@14
    87
            <classpath>
jaroslav@14
    88
                <pathelement location="${apiB}"/>
jaroslav@14
    89
                <pathelement location="${junit.jar}"/>
jaroslav@14
    90
            </classpath>
jaroslav@14
    91
        </javac>
jaroslav@14
    92
jaroslav@14
    93
        
jaroslav@14
    94
        <uptodate property="compilation.failed">
jaroslav@14
    95
            <srcfiles dir="${build.b}" includes="**/*.class"/>
jaroslav@14
    96
            <mapper type="glob" from="*" to="build/tests/*"/>
jaroslav@14
    97
        </uptodate>
jaroslav@14
    98
        
jaroslav@14
    99
jaroslav@14
   100
    </target>
jaroslav@14
   101
    
jaroslav@14
   102
    <target name="test" depends="run"/>
jaroslav@14
   103
    
jaroslav@14
   104
    <target name="clean">
jaroslav@14
   105
        <delete dir="build"/>
jaroslav@14
   106
    </target>
jaroslav@14
   107
</project>