<?xml version="1.0" encoding="UTF-8"?>
<!--

The contents of this file are subject to the terms of the Common Development
and Distribution License (the License). You may not use this file except in
compliance with the License.

You can obtain a copy of the License at http://www.netbeans.org/cddl.html
or http://www.netbeans.org/cddl.txt.

When distributing Covered Code, include this CDDL Header Notice in each file
and include the License file at http://www.netbeans.org/cddl.txt.
If applicable, add the following below the CDDL Header, with the fields
enclosed by brackets [] replaced by your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"

The Original Software is NetBeans. The Initial Developer of the Original
Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
Microsystems, Inc. All Rights Reserved.
-->

<project name="xtest" default="all" basedir=".">

    <import file="../default.xml"/>
    <import file="emma.xml"/>

    <!-- Home of XTest -->
    <property name="xtest.home" location="${nb_all}/xtest"/>

    <!-- ****************************************************** -->
    <!-- ** You should not change anything after this comment,  -->
    <!-- **    unless you really know what you are doing        -->
    <!-- ****************************************************** -->

    <!-- Ant property. Value 'ignore' means that system classpath is ignored -->
    <!-- and only classpath specified in build file is used. -->
    <property name="build.sysclasspath" value="ignore"/>
    
    <!-- Points to antfile with module's harness. --> 
    <!-- Targets from that antfile is called from this build.xml -->
    <property name="xtest.module_harness.antfile" location="${xtest.home}/lib/module_harness.xml"/>
    
    <!-- before using xtest task, it has to be defined -->
    <taskdef name="xtest" classname="org.netbeans.xtest.usertasks.XTestActionTask" classpath="${xtest.home}/lib/xtest.jar"/>
    
    <!-- ============ -->
    <!-- Main targets -->
    <!-- ============ -->
    <target name="all" depends="runtests" description="Builds and runs tests."/>
    
    <!-- This calls target which will call compilers according to cfg file. -->
    <!-- You should not change this target unless you realy know what you are doing. -->
    <target name="buildtests" depends="call-bootstrap,init" 
            description="Builds the test files.">
    	<xtest executeAction="buildTests"/>
    </target>
    
    <!--  This calls common clean process. This cleans the tests. -->
    <!--  You can write your own if you need something special. -->
    <target name="cleantests" description="Deletes the test files.">
    	<xtest executeAction="cleanTests"/>
    </target>
    
    <!-- This target runs tests. You should not change this -->
    <!-- target unless you realy know what you are doing. -->
    <target name="runtests" depends="buildtests" description="Executes tests.">
    	<echo message="Module: Running tests for ${xtest.module}, testtype ${xtest.testtype}, attribs=${xtest.attribs}"/>
	<xtest executeAction="runTests"/>
    </target>
    
    <!-- This target cleans test results. -->
    <target name="cleanresults" description="Deletes the results files.">
    	<xtest executeAction="cleanResults"/>
    </target>
    
    <!-- This target cleans both tests and results. -->
    <target name="realclean" description="Delete both test and results files.">
    	<xtest executeAction="cleanAll"/>
    </target>
    
    <!-- This target prints out default xtest configuration which will be used to run the tests. -->
    <target name="printconfig" 
            description="Prints xtest configuration for tests.">
    	<echo message="Default config is testtype: ${xtest.testtype}, attributes: ${xtest.attribs}."/>
    </target>
    
    <!-- This target runs main method of given class in IDE's JVM. 
         It is available only when apisupport module is installed and only for 
         functional tests. -->
    <target name="internal-execution">
        <!-- Build test before execution  -->
        <antcall target="buildtests">
            <!-- Property has to be set to any not empty value. If not it can
                 happen that the selected class is not built because of not
                 matching xtest attributes. -->
            <param name="xtest.run.singletest" value="true"/>
        </antcall>
        <ant antfile="build-qa-functional.xml" target="internal-execution"/>
    </target>

    <!-- Calls bootstrap target from nbbuild/build.xml to satisfy that nbantext.jar is ready -->
    <target name="call-bootstrap" depends="check-bootstrap" unless="bootstrap-ready">
        <ant dir="${nb_all}/nbbuild" target="bootstrap"/>
    </target>

    <!-- Checks nbantext.jar is up to date -->
    <target name="check-bootstrap">
        <condition property="bootstrap-ready">
            <or>
                <isset property="xtest.distexec"/>
                <uptodate targetfile="${nb_all}/nbbuild/nbantext.jar">
                    <srcfiles dir= "${nb_all}/nbbuild/antsrc"/>
                </uptodate>
            </or>
        </condition>
    </target>
    
    <target name="show-results-nb" if="netbeans.home">
        <nbbrowse file="results/index.html"/>
    </target>

</project>
