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