Author: hindessm
Date: Tue Apr 20 19:57:12 2010
New Revision: 936048
URL: http://svn.apache.org/viewvc?rev=936048&view=rev
Log:
Add crashed test checking and short/full report to hdk test wrapper.
Modified:
harmony/enhanced/java/trunk/classlib/make/run-test.xml
Modified: harmony/enhanced/java/trunk/classlib/make/run-test.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/make/run-test.xml?rev=936048&r1=936047&r2=936048&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/make/run-test.xml (original)
+++ harmony/enhanced/java/trunk/classlib/make/run-test.xml Tue Apr 20 19:57:12 2010
@@ -26,12 +26,31 @@
<property name="target.dir" value="." />
<property name="work.dir" value="${target.dir}" />
<property name="tests.output" value="${work.dir}/report" />
+ <property name="report.dir" value="${tests.output}/html" />
<property name="junit.jar" value="${target.dir}/junit.jar" />
+ <property name="gen.report" value="true" />
+ <condition property="do.full.report" value="true">
+ <and>
+ <equals arg1="${gen.report}" arg2="true" />
+ <not><equals arg1="${short.report}" arg2="true" /></not>
+ </and>
+ </condition>
+ <condition property="do.short.report" value="true">
+ <and>
+ <equals arg1="${gen.report}" arg2="true" />
+ <equals arg1="${short.report}" arg2="true" />
+ </and>
+ </condition>
+
<import file="../ant/properties.xml" />
<target name="test"
- depends="test-jre-vm-info,-test,gen-report,check-test-result" />
+ depends="test-jre-vm-info,-test,check-test-result" />
+
+ <target name="clean">
+ <delete dir="${tests.output}" />
+ </target>
<target name="-test">
<echo message="Test Work Dir: ${work.dir}" />
@@ -41,23 +60,94 @@
<poll-modules dir="." target="test-module" />
</target>
- <target name="check-test-result">
- <available property="test.errors" file="${work.dir}/report/test.errors" />
- <available property="test.failures" file="${work.dir}/report/test.failures" />
+ <target name="check-test-result" depends="-check-crashed,gen-report">
+ <fail if="test.crashes"
+ message="There were test crashes: ${crashed.tests}"/>
+ <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="gen-report">
- <junitreport todir="${tests.output}">
+ <target name="-check-crashed" 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="<?xml version='1.0' encoding='UTF-8' ?><testsuite
errors='1' name='vmcrash.CrashedTests' time='0'>"/>
+ <property name="per.prefix" value="<testcase classname='"/>
+ <property name="per.middle" value="' name='"/>
+ <property name="per.suffix"
+ value="' time='0.0'><error message='VM crash?'/></testcase>"/>
+ <property name="per.footer" value="</testsuite>"/>
+
+ <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>
+
+ <!-- Need to ensure the file is UTF-8 on non-ASCII platforms -->
+ <move file="${per.crashed.tests.file}"
+ tofile="${per.crashed.tests.file}.orig" />
+ <copy file="${per.crashed.tests.file}.orig"
+ tofile="${per.crashed.tests.file}" outputencoding="UTF-8" />
+ <delete file="${per.crashed.tests.file}.orig" />
+
+ </target>
+
+ <target name="gen-report" depends="-short-report,-full-report">
+ <!-- this property is simply to fix slashes in displayed string -->
+ <property name="display-location" location="${report.dir}/index.html"/>
+ <echo message="The test report is in ${display-location}"/>
+ </target>
+
+ <target name="-full-report" if="do.full.report">
+ <mkdir dir="${report.dir}" />
+ <junitreport todir="${report.dir}">
<fileset dir="${tests.output}">
<include name="TEST*-*.xml" />
</fileset>
- <report format="frames" todir="${tests.output}" />
+ <report format="frames" todir="${report.dir}" />
+ </junitreport>
+ </target>
+
+ <target name="-short-report" unless="do.full.report">
+ <mkdir dir="${report.dir}" />
+ <junitreport todir="${report.dir}">
+ <fileset dir="${tests.output}" includes="TEST*-*.xml">
+ <containsregexp expression='(errors|failures)=.[1-9]' />
+ <exclude name="TESTS-TestSuites.xml" />
+ </fileset>
+ <report format="frames" todir="${report.dir}" />
</junitreport>
- <property name="display-location"
- location="${tests.output}/index.html"/>
- <echo message="The test report is in ${display-location}"/>
</target>
</project>
|