blob: b6fa6566ef8815bc64e27a7f370df79bc07b9db7 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="jdktools-test" default="test-all" basedir="..">
<description>Tests for classlib package</description>
<!-- import common properties -->
<import file="${basedir}/make/properties.xml" />
<!-- set global properties for this build. -->
<property name="tests.output" location="build/test_report" />
<condition property="not.copy.jre">
<isset property="test.jre.home"/>
</condition>
<property name="test.jre.home" location="${jdktools.deploy.dir}" />
<property name="tests.build.output" location="build/tests" />
<property name="tests.depends.jars" location="${hy.hdk}/jdk/jre/lib/boot" />
<!-- this list of components to test will grow to eventually be all modules -->
<target name="test-all"
depends="clean-tests-output, test-modules, process-test-output" />
<target name="process-test-output"
depends="process-empty, gen-report, check-test-result" />
<target name="clean" depends="clean-tests-output, clean-tests, clean-jre" />
<target name="clean-tests">
<delete dir="${tests.build.output}" />
</target>
<target name="clean-tests-output">
<delete dir="${tests.output}" />
</target>
<target name="test-modules" depends="copy-jre" >
<mkdir dir="${tests.output}" />
<mkdir dir="${tests.build.output}" />
<call-modules target="test-module" />
</target>
<target name="gen-report" depends="full-report,short-report" />
<target name="full-report" unless="short.report" >
<junitreport todir="${tests.output}">
<fileset dir="${tests.output}">
<include name="TEST*-*.xml"/>
</fileset>
<report format="frames" todir="${tests.output}/html"/>
</junitreport>
<!-- use this property just to get the slashes to display right in the echo -->
<property name="display-location" location="${tests.output}/html/index.html"/>
<echo message="The test report is in ${display-location}"/>
</target>
<target name="short-report" if="short.report" >
<junitreport todir="${tests.output}">
<fileset dir="${tests.output}" includes="TEST*-*.xml">
<containsregexp expression='(errors|failures)="[1-9]' />
<exclude name="TESTS-TestSuites.xml" />
</fileset>
<report format="frames" todir="${tests.output}/html"/>
</junitreport>
<!-- use this property just to get the slashes to display right in the echo -->
<property name="display-location" location="${tests.output}/html/index.html"/>
<echo message="The short test report is in ${display-location}"/>
</target>
<target name="check-test-result">
<available property="test.errors"
file="${tests.output}/test.errors" />
<available property="test.failures"
file="${tests.output}/test.failures" />
<fail if="test.errors" message="There were test errors." />
<fail if="test.failures" message="There were test failures." />
</target>
<target name="copy-jre" depends="copy-jre-files, chmod-jre-files" unless="not.copy.jre"/>
<target name="copy-jre-files" unless="not.copy.jre">
<copy todir="${jdktools.deploy.dir}/jre" overwrite="no">
<fileset dir="${hy.deploy}/jdk/jre" />
</copy>
</target>
<target name="chmod-jre-files" if="is.unix" unless="not.copy.jre">
<chmod file="${jdktools.deploy.dir}/jre/bin/java" perm="ugo+x" />
</target>
<target name="clean-jre">
<delete dir="${jdktools.deploy.dir}/jre" />
</target>
<target name="process-empty" depends="-check-for-empty, -process-empty"/>
<target name="-check-for-empty">
<fileset id="empty.test.reports" dir="${tests.output}">
<patternset>
<include name="TEST-*.xml"/>
</patternset>
<size value="0" when="equal"/>
</fileset>
<pathconvert refid="empty.test.reports" pathsep="${path.separator}"
property="crashed.tests"/>
<condition property="test.crashes">
<not>
<equals arg1="" arg2="${crashed.tests}" />
</not>
</condition>
</target>
<target name="-process-empty" if="test.crashes">
<property name="per.crashed.tests.file"
value="${tests.output}${file.separator}TEST-crashed.xml"/>
<property name="per.header"
value="&lt;?xml version='1.0' encoding='UTF-8' ?&gt;&lt;testsuite errors='1' name='vmcrash.CrashedTests' time='0'&gt;"/>
<property name="per.prefix"
value="&lt;testcase classname='"/>
<property name="per.middle" value="' name='"/>
<property name="per.suffix"
value="' time='0.0'&gt;&lt;error message='VM crash?'/&gt;&lt;/testcase&gt;"/>
<property name="per.footer" value="&lt;/testsuite&gt;"/>
<echo message="${crashed.tests}" file="${per.crashed.tests.file}"/>
<replaceregexp file="${per.crashed.tests.file}" flags="g">
<regexp pattern="[^${path.separator}]*TEST-([^${path.separator}]*)\.xml${path.separator}?"/>
<substitution expression="${per.prefix}\1${per.middle}\1${per.suffix}"/>
</replaceregexp>
<replaceregexp file="${per.crashed.tests.file}" match="\A"
replace="${per.header}"/>
<echo file="${per.crashed.tests.file}" append="yes"
message="${per.footer}"/>
<!-- now let's delete empty reports -->
<delete><fileset refid="empty.test.reports"/></delete>
</target>
</project>