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