summaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorBaptiste Lepilleur <gaiacrtn@free.fr>2005-06-14 20:59:34 +0000
committerBaptiste Lepilleur <gaiacrtn@free.fr>2005-06-14 20:59:34 +0000
commit9efb5318f845c9f5d90a8a5c3bc6cec6ea82cc60 (patch)
tree3197935276647078fe10fbde03a1d3a07f8fff2d /contrib
parentf267542d4b5c64fd565ce8be950e274ee4b96136 (diff)
Contrib/xml-xsl/cppunit2junit.
contrib/xml-xsl/cppunit2junit.txt * contrib/xml-xsl/cppunit2junit.xsl * contrib/readme.txt: XSLT for compatibility with Ant junit xml formatter. Patch #1112053 contributed by Norbert Barbosa.
Diffstat (limited to 'contrib')
-rw-r--r--contrib/readme.txt6
-rw-r--r--contrib/xml-xsl/cppunit2junit.txt60
-rw-r--r--contrib/xml-xsl/cppunit2junit.xsl48
3 files changed, 113 insertions, 1 deletions
diff --git a/contrib/readme.txt b/contrib/readme.txt
index c06c9f1..658b870 100644
--- a/contrib/readme.txt
+++ b/contrib/readme.txt
@@ -21,4 +21,8 @@ xml-xsl/:
* report.xsl: a xml style sheet contributed by 'cuppa' project team
(http://sourceforge.jp/projects/cuppa/) to transform CppUnit XML output into
HTML. Windows user can test it by running tests.xml (require Internet Explorer
-5.0+). \ No newline at end of file
+5.0+).
+
+ * cppunit2junit.xsl: XSLT for compatibility with Ant junit xml formatter
+ (patch #1112053 contributed by BARBOSA Norbert.
+ See cppunit2junit.txt for details). \ No newline at end of file
diff --git a/contrib/xml-xsl/cppunit2junit.txt b/contrib/xml-xsl/cppunit2junit.txt
new file mode 100644
index 0000000..941ecb1
--- /dev/null
+++ b/contrib/xml-xsl/cppunit2junit.txt
@@ -0,0 +1,60 @@
+ A simple XSLT file to transform cppunit XmlOutputer
+result file, to the same format that the apache Ant
+junit task produce:
+<target name="test">
+<junit printsummary="no" forkmode="once"
+fork="true">
+<formatter type="xml"/>
+...
+
+This format allows to manage result file with the Ant
+junitreport task.
+example usage inside a ant task:
+
+task similar to the junit task:
+<target name = "test.cxx">
+<!-- assume that the exe take a '-xml
+filename', and exit with code error 1 if failed -->
+<exec dir = "${dev.build}/bin"
+executable = "${dev.build}/bin/test.exe"
+failonerror = "true"
+failifexecutionfails = "true"
+resultproperty = "test.ret" >
+<arg line = "-xml
+${dev.build}/test/data/temp-cxx-results.xml" />
+</exec>
+<condition property = "test.failed">
+<equals arg1="${test.ret}" arg2="1"/>
+</condition>
+<!-- transform the cppunit xml file to junit
+xml file -->
+<xslt
+in="${dev.build}/test/data/temp-cxx-results.xml"
+
+out="${dev.build}/test/data/TEST-cxx-results.xml"
+
+style="${dev.lib}/cxx/cppunit/cppunit2junit.xsl"/>
+
+<fail if="test.failed">
+Unit tests failed. For error messages, check
+the log files in
+${dev.build}/test/data or run "ant test-reports"
+to generate reports at
+${test.dir}/reports.</fail>
+</target>
+
+task that use generated xml result, to produce html report:
+<target name="test-reports" description="Generate
+test reports from data collected after a running test">
+<mkdir dir="${dev.build}/test/reports"/>
+<junitreport todir="${dev.build}/test">
+<fileset dir="${dev.build}/test/data">
+<include name="TEST-*.xml"/>
+</fileset>
+<report format="frames"
+todir="${dev.build}/test/reports"/>
+</junitreport>
+</target>
+
+BARBOSA Norbert - patch #1112053
+http://sourceforge.net/tracker/index.php?func=detail&aid=1112053&group_id=11795&atid=311795
diff --git a/contrib/xml-xsl/cppunit2junit.xsl b/contrib/xml-xsl/cppunit2junit.xsl
new file mode 100644
index 0000000..832f444
--- /dev/null
+++ b/contrib/xml-xsl/cppunit2junit.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml" indent="yes"/>
+ <xsl:template match="/">
+ <testsuite>
+ <xsl:attribute name="errors">
+ <xsl:value-of select="TestRun/Statistics/Errors"/>
+ </xsl:attribute>
+ <xsl:attribute name="failures">
+ <xsl:value-of select="TestRun/Statistics/Failures"/>
+ </xsl:attribute>
+ <xsl:attribute name="tests">
+ <xsl:value-of select="TestRun/Statistics/Tests"/>
+ </xsl:attribute>
+ <xsl:attribute name="name">from cppunit</xsl:attribute>
+ <xsl:apply-templates/>
+ </testsuite>
+ </xsl:template>
+ <xsl:template match="/TestRun/SuccessfulTests/Test">
+ <testcase>
+ <xsl:attribute name="classname" ><xsl:value-of select="substring-before(Name, '::')"/></xsl:attribute>
+ <xsl:attribute name="name"><xsl:value-of select="substring-after(Name, '::')"/></xsl:attribute>
+ </testcase>
+ </xsl:template>
+ <xsl:template match="/TestRun/FailedTests/FailedTest">
+ <testcase>
+ <xsl:attribute name="classname" ><xsl:value-of select="substring-before(Name, '::')"/></xsl:attribute>
+ <xsl:attribute name="name"><xsl:value-of select="substring-after(Name, '::')"/></xsl:attribute>
+ <error>
+ <xsl:attribute name="message">
+ <xsl:value-of select=" normalize-space(Message)"/>
+ </xsl:attribute>
+ <xsl:attribute name="type">
+ <xsl:value-of select="FailureType"/>
+ </xsl:attribute>
+ <xsl:value-of select="Message"/>
+ File:<xsl:value-of select="Location/File"/>
+ Line:<xsl:value-of select="Location/Line"/>
+ </error>
+ </testcase>
+ </xsl:template>
+ <!-- skip all text -->
+ <xsl:template match="text()|@*"/>
+</xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2001 eXcelon Corp.
+<metaInformation>
+<scenarios ><scenario default="yes" name="test" userelativepaths="yes" url="..\..\..\..\..\Tmp\xml\cppunit.xml" htmlbaseurl="" processortype="internal" commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext=""/></scenarios><MapperInfo srcSchemaPath="..\..\..\..\..\Tmp\xml\cppunit.xml" srcSchemaRoot="TestRun" srcSchemaPathIsRelative="yes" destSchemaPath="..\..\..\..\..\Tmp\xml\TEST&#x2D;test.osmoose.license.TestUtils.xml" destSchemaRoot="testsuite" destSchemaPathIsRelative="yes" />
+</metaInformation>
+--> \ No newline at end of file