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