<!-- Common properties/tasks that are shared by all projects

However, for possible overrides, these are all prefixed by
"_shared.common."

 @version: $Date: 2004/05/14 18:54:10 $
 -->
    <target name="_shared.common.test-all"
        depends="init,test-checkDependencies,
            _shared.common.test-eut,
            _shared.common.test-ut,
            _shared.common.test-iut,
            _shared.common.test-report,
            _shared.common.test-failed,
            _shared.common.test-errored" >
        <echo>
        *** The AIT tests did not run. ***
        To run them, execute the target "run-ait-tests"
        *** The AIT tests did not run. ***
        </echo>
    </target>
    
    <target name="_shared.common.test-report"
            depends="_shared.common.test-junit.report,
                     _shared.common.test-coverage.report">
        <copy todir="${dirs.work}">
            <fileset dir="${dirs.test-output}" includes="*.html" />
            <fileset dir="${dirs.coverage}" includes="*.html" />
        </copy>
    </target>
    
    <target name="_shared.common.test-junit.report">
        <junitreport todir="${dirs.test-output}" >
            <fileset dir="${dirs.test-output}" >
                <include name="TEST-*.xml" />
            </fileset>
            <report format="noframes" todir="${dirs.test-output}"/>
        </junitreport>
    </target>
    
    
    <target name="_shared.common.test-failed" if="tests.failure" >
        <fail message="jUnit failure(s)" />
    </target>
    
    <target name="_shared.common.test-errored" if="tests.error" >
        <fail message="jUnit error(s)" />
    </target>
    
    
    <target name="_shared.common.test-coverage.compile" >
        <delete dir="${dirs.coverage}/classes" failonerror="false" />
        <mkdir dir="${dirs.coverage}/classes" />
        <grobo-instrument logdir="${dirs.coverage}/logs"
                logger="single"
                destdir="${dirs.coverage}/classes">
            <fileset dir="${dirs.classes.dev}">
                <include name="*.class" />
                <include name="**/*.class" />
                
                <!-- for recursion issues, we can't cover part of the
                coverage group -->
                <exclude name="**/codecoverage/v2/logger/*.class" />
            </fileset>
            
            <measure type="linecount" />
            <!-- <measure type="bytecode" /> -->
            <!-- <measure type="branch" /> -->
            <!-- <measure type="call-pair" /> -->
            <!-- <measure type="function" /> -->
            
            <loggerProp key="writes-per-flush" value="-1" />
            <loggerProp key="use-cache" value="true" />
            <loggerProp key="millis-per-flush" value="0" />
        </grobo-instrument>
    </target>
    
    
    <target name="_shared.common.test-coverage.report" >
        <grobo-report logdir="${dirs.coverage}/logs">
            <logFilter type="single" />
            
            <simple destdir="${dirs.coverage}" />
            <source destdir="work/coverage/report"
                title="GroboUtils Coverage for ${product}-${version}"
                srcdir="${dirs.sources.dev}" />
            <failon percentage="60" />
        </grobo-report>
    </target>
    
    
    <!-- Setup the classes to test (allows for command-line declaration
    of which tests to run) -->
    <target name="_shared.common.test-filter"
        depends="_shared.common.test-filter.1,_shared.common.test-filter.2" />
    <target name="_shared.common.test-filter.1" if="testfilter">
        <property name="_shared.testfilter"
            value="**/${testfilter}Test.class" />
    </target>
    <target name="_shared.common.test-filter.2" unless="testfilter">
        <property name="_shared.testfilter"
            value="**/*Test.class" />
    </target>
    

        
    <target name="_shared.common.test-eut"
            depends="init, _shared.common.test-coverage.compile,
                _shared.common.test-filter">
        <!-- <delete dir="${dirs.test-output}" /> -->
        <mkdir dir="${dirs.test-output}" />
        <echoproperties destfile="${dirs.test-output}/eut.properties" />
        
        <junit printsummary="yes" fork="yes"
            haltonerror="no" haltonfailure="no"
            failureProperty="tests.failure"
            errorProperty="tests.error"
            dir="${dirs.test-output}"
            >
            <classpath>
                <pathelement location="${dirs.coverage}/classes" />
                <pathelement location="${output.jar-name.dev}" />
                <pathelement location="${output.jar-name.eut}" />
                <path refid="classpath.tests" />
                
                <path refid="classpath.bootstrap.grobocoverage.runtime" />
                <path refid="classpath.bootstrap.xml" />
                <path refid="classpath.bootstrap.core" />
            </classpath>
            <formatter type="xml" usefile="yes" />
            <formatter
                classname="net.sourceforge.groboutils.autodoc.v1.junit.AutoDocJUnitFormatter"
                extension="ignore" usefile="no" />
            <batchtest todir="${dirs.test-output}">
                <fileset dir="${dirs.classes.eut}">
                    <include name="${_shared.testfilter}" />
                    <exclude name="**/*$$*.class" />

                    <!-- tests excluded if the test is run in offline mode -->
                    <patternset refid="testset.onlinetests"/>
                    
                    <!-- exclude JDK 1.2 specific tests unless we're running
                        JDK 1.2 compatible JVM -->
                    <patternset refid="testset.jdk12tests"/>
                    
                    <!-- exclude JDK 1.3 specific tests unless we're running
                        JDK 1.3 compatible JVM -->
                    <patternset refid="testset.jdk13tests"/>
                    
                    <!-- exclude JDK 1.4 specific tests unless we're running
                        JDK 1.4 compatible JVM -->
                    <patternset refid="testset.jdk14tests"/>
                </fileset>
            </batchtest>
            
            <sysproperty
                key="junit.ant.properties"
                value="${dirs.test-output}/eut.properties"
            />
        </junit>
    </target>
        
    <target name="_shared.common.test-ut"
            depends="init, _shared.common.test-coverage.compile,
                _shared.common.test-filter">
        <mkdir dir="${dirs.test-output}" />
        <echoproperties destfile="${dirs.test-output}/ut.properties" />
        
        <junit printsummary="yes" fork="yes"
            haltonerror="no" haltonfailure="no"
            failureProperty="tests.failure"
            errorProperty="tests.error"
            dir="${dirs.test-output}"
            >
            <classpath>
                <pathelement location="${dirs.coverage}/classes" />
                <pathelement location="${output.jar-name.dev}" />
                <pathelement location="${output.jar-name.ut}" />
                <pathelement location="${output.jar-name.eut}" />
                <path refid="classpath.tests" />
                
                <path refid="classpath.bootstrap.grobocoverage.runtime" />
                <path refid="classpath.bootstrap.xml" />
                <path refid="classpath.bootstrap.core" />
            </classpath>
            <!--
            <formatter type="plain" usefile="no" />
            -->
            <formatter type="xml" usefile="yes" />
            <formatter
                classname="net.sourceforge.groboutils.autodoc.v1.junit.AutoDocJUnitFormatter"
                extension="ignore" usefile="no" />
            <batchtest todir="${dirs.test-output}">
                <fileset dir="${dirs.classes.ut}">
                    <include name="${_shared.testfilter}" />
                    <exclude name="**/*$$*.class" />

                    <!-- tests excluded if the test is run in offline mode -->
                    <patternset refid="testset.onlinetests"/>
                    
                    <!-- exclude JDK 1.2 specific tests unless we're running
                        JDK 1.2 compatible JVM -->
                    <patternset refid="testset.jdk12tests"/>
                    
                    <!-- exclude JDK 1.3 specific tests unless we're running
                        JDK 1.3 compatible JVM -->
                    <patternset refid="testset.jdk13tests"/>
                    
                    <!-- exclude JDK 1.4 specific tests unless we're running
                        JDK 1.4 compatible JVM -->
                    <patternset refid="testset.jdk14tests"/>
                </fileset>
            </batchtest>
            
            <sysproperty
                key="junit.ant.properties"
                value="${dirs.test-output}/ut.properties"
            />
        </junit>
    </target>
        
    <target name="_shared.common.test-iut"
            depends="init, _shared.common.test-coverage.compile,
                _shared.common.test-filter">
        <mkdir dir="${dirs.test-output}" />
        <echoproperties destfile="${dirs.test-output}/iut.properties" />
        
        <junit printsummary="yes" fork="yes"
            haltonerror="no" haltonfailure="no"
            failureProperty="tests.failure"
            errorProperty="tests.error"
            dir="${dirs.test-output}"
            >
            <classpath>
                <pathelement location="${dirs.coverage}/classes" />
                <pathelement location="${output.jar-name.dev}" />
                <pathelement location="${output.jar-name.iut}" />
                <pathelement location="${output.jar-name.ut}" />
                <pathelement location="${output.jar-name.eut}" />
                <path refid="classpath.tests" />
                
                <path refid="classpath.bootstrap.grobocoverage.runtime" />
                <path refid="classpath.bootstrap.xml" />
                <path refid="classpath.bootstrap.core" />
            </classpath>
            <formatter type="xml" usefile="yes" />

            <formatter
                classname="net.sourceforge.groboutils.autodoc.v1.junit.AutoDocJUnitFormatter"
                extension="ignore" usefile="no" />
            <batchtest todir="${dirs.test-output}">
                <fileset dir="${dirs.classes.iut}">
                    <include name="${_shared.testfilter}" />
                    <exclude name="**/*$$*.class" />

                    <!-- tests excluded if the test is run in offline mode -->
                    <patternset refid="testset.onlinetests"/>
                    
                    <!-- exclude JDK 1.2 specific tests unless we're running
                        JDK 1.2 compatible JVM -->
                    <patternset refid="testset.jdk12tests"/>
                    
                    <!-- exclude JDK 1.3 specific tests unless we're running
                        JDK 1.3 compatible JVM -->
                    <patternset refid="testset.jdk13tests"/>
                    
                    <!-- exclude JDK 1.4 specific tests unless we're running
                        JDK 1.4 compatible JVM -->
                    <patternset refid="testset.jdk14tests"/>
                </fileset>
            </batchtest>
            <sysproperty
                key="junit.ant.properties"
                value="${dirs.test-output}/iut.properties"
            />
        </junit>
    </target>
    
    
    <target name="_shared.common.test-ait.function-online"
            unless="global.offline" >
        <antcall target="_shared.common.test-ait.function" />
    </target>
    
    
    
    <target name="_shared.common.test-ait.function" >
        <!-- entry assertion -->
        <fail unless="test-ait.function.name">
Must pass 'test-ait.function.name' to this target to run an AIT test.
        </fail>
        
        <mkdir dir="${dirs.test-output}" />
        
        <echoproperties destfile="${dirs.test-output}/ait.properties" />
        
        <junit printsummary="yes" fork="yes"
            haltonerror="no" haltonfailure="no"
            failureProperty="tests.failure"
            errorProperty="tests.error"
            dir="${dirs.test-output}"
            >
            <classpath>
                <pathelement location="${dirs.coverage}/classes" />
                <pathelement location="${output.jar-name.dev}" />
                <pathelement location="${output.jar-name.ait}" />
                <pathelement location="${output.jar-name.iut}" />
                <pathelement location="${output.jar-name.ut}" />
                <pathelement location="${output.jar-name.eut}" />
                <path refid="classpath.tests" />
                
                <path refid="classpath.bootstrap.grobocoverage.runtime" />
                <path refid="classpath.bootstrap.xml" />
                <path refid="classpath.bootstrap.core" />
            </classpath>
            <formatter type="xml" usefile="yes" />
            <formatter
                classname="net.sourceforge.groboutils.testing.junitlog.v1.JUnitBugResultFormatter"
                extension="ignore" usefile="no" />
            
            <test name="${test-ait.function.name}" todir="${dirs.test-output}" />
            <sysproperty
                key="junit.ant.properties"
                value="${dirs.test-output}/ait.properties"
            />
        </junit>
    </target>
    
