samples/apifest1/day3-intermezzo/jtulach/against-welltestedsolution/build.xml
author Jaroslav Tulach <jtulach@netbeans.org>
Sat, 14 Jun 2008 09:52:48 +0200
changeset 54 45b0d58e66ca
child 55 5a0b7b1f8f11
permissions -rw-r--r--
Getting the solutions from the CVS, not just from the ZIP file
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@54
    15
        <javac destdir="build/tests" srcdir="test">
jtulach@54
    16
            <classpath>
jtulach@54
    17
                <pathelement location="${apiA}"/>
jtulach@54
    18
                <pathelement location="${apifest}/lib/junit-3.8.2.jar"/>
jtulach@54
    19
            </classpath>
jtulach@54
    20
        </javac>
jtulach@54
    21
    </target>
jtulach@54
    22
    
jtulach@54
    23
    <target name="run" depends="-run-binary-check,-run-source-check">
jtulach@54
    24
        <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
    25
            <condition>
jtulach@54
    26
                <not><or>
jtulach@54
    27
                    <isset property="execution.failed"/>
jtulach@54
    28
                    <isset property="compilation.failed"/>
jtulach@54
    29
                </or></not>
jtulach@54
    30
            </condition>
jtulach@54
    31
        </fail>
jtulach@54
    32
    </target>
jtulach@54
    33
        
jtulach@54
    34
    <target name="-run-binary-check" depends="compile">
jtulach@54
    35
        <mkdir dir="build/testresultA"/>
jtulach@54
    36
        <junit dir="build/tests" failureproperty="run.on.A.shall.succeed">
jtulach@54
    37
            <batchtest todir="build/testresultA">
jtulach@54
    38
                <fileset dir="test" includes="**/*.java"/>
jtulach@54
    39
            </batchtest>
jtulach@54
    40
            <formatter type="brief" usefile="false"/>
jtulach@54
    41
            <formatter type="xml"/>
jtulach@54
    42
            <classpath>
jtulach@54
    43
                <pathelement location="${apiA}"/>
jtulach@54
    44
                <pathelement location="${apifest}/lib/junit-3.8.2.jar"/>
jtulach@54
    45
                <pathelement location="build/tests"/>
jtulach@54
    46
            </classpath>
jtulach@54
    47
        </junit>
jtulach@54
    48
        
jtulach@54
    49
        <mkdir dir="build/testresultB"/>
jtulach@54
    50
        <junit dir="build/tests" failureproperty="run.on.B.shall.fail">
jtulach@54
    51
            <batchtest todir="build/testresultB">
jtulach@54
    52
                <fileset dir="test" includes="**/*.java"/>
jtulach@54
    53
            </batchtest>
jtulach@54
    54
            <formatter type="brief" usefile="false"/>
jtulach@54
    55
            <formatter type="xml"/>
jtulach@54
    56
            <classpath>
jtulach@54
    57
                <pathelement location="${apiB}"/>
jtulach@54
    58
                <pathelement location="${apifest}/lib/junit-3.8.2.jar"/>
jtulach@54
    59
                <pathelement location="build/tests"/>
jtulach@54
    60
            </classpath>
jtulach@54
    61
        </junit>
jtulach@54
    62
        
jtulach@54
    63
        <condition property="execution.failed">
jtulach@54
    64
            <and>
jtulach@54
    65
                <isset property="run.on.B.shall.fail"/>
jtulach@54
    66
                <not><isset property="run.on.A.shall.succeed"/></not>
jtulach@54
    67
            </and>
jtulach@54
    68
        </condition>
jtulach@54
    69
    </target>
jtulach@54
    70
    
jtulach@54
    71
    <target name="-run-source-check" depends="compile" unless="execution.failed">
jtulach@54
    72
        
jtulach@54
    73
        <property name="build.b" location="build/verifyitbuildsagainstB"/>
jtulach@54
    74
        <delete dir="${build.b}"/>
jtulach@54
    75
        <mkdir dir="${build.b}"/>
jtulach@54
    76
        <javac destdir="${build.b}" srcdir="test" failonerror="false">
jtulach@54
    77
            <classpath>
jtulach@54
    78
                <pathelement location="${apiB}"/>
jtulach@54
    79
                <pathelement location="${apifest}/lib/junit-3.8.2.jar"/>
jtulach@54
    80
            </classpath>
jtulach@54
    81
        </javac>
jtulach@54
    82
jtulach@54
    83
        
jtulach@54
    84
        <uptodate property="compilation.failed">
jtulach@54
    85
            <srcfiles dir="${build.b}" includes="**/*.class"/>
jtulach@54
    86
            <mapper type="glob" from="*" to="build/tests/*"/>
jtulach@54
    87
        </uptodate>
jtulach@54
    88
        
jtulach@54
    89
jtulach@54
    90
    </target>
jtulach@54
    91
    
jtulach@54
    92
    <target name="test" depends="run"/>
jtulach@54
    93
    
jtulach@54
    94
    <target name="clean">
jtulach@54
    95
        <delete dir="build"/>
jtulach@54
    96
    </target>
jtulach@54
    97
</project>