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