diff options
Diffstat (limited to 'old/scripts/qtestxml2junitxml.xsl')
-rw-r--r-- | old/scripts/qtestxml2junitxml.xsl | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/old/scripts/qtestxml2junitxml.xsl b/old/scripts/qtestxml2junitxml.xsl new file mode 100644 index 0000000..aab2d0f --- /dev/null +++ b/old/scripts/qtestxml2junitxml.xsl @@ -0,0 +1,82 @@ +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> + +<xsl:output method="xml" indent="yes" /> +<xsl:decimal-format decimal-separator="." grouping-separator="," /> + +<!-- misc variables --> +<xsl:variable name="classname" select="/TestCase/@name" /> +<xsl:variable name="total-tests" select="count(/TestCase/TestFunction)" /> +<xsl:variable name="total-failures" select="count(/TestCase/TestFunction/Incident[@type='fail'])" /> + +<!-- main template call --> +<xsl:template match="/"> + <xsl:apply-templates select="TestCase"/> +</xsl:template> + +<xsl:template match="TestCase"> + <testsuite name="{$classname}" tests="{$total-tests}" failures="{$total-failures}" errors="0" time="0.0"> + <xsl:apply-templates select="Environment"/> + <xsl:apply-templates select="TestFunction" /> + <xsl:call-template name="display-system-out" /> + <xsl:call-template name="display-system-err" /> + </testsuite> +</xsl:template> + +<xsl:template match="Environment"> + <properties> + <xsl:for-each select="*"> + <property name="{name()}" value="{text()}" /> + </xsl:for-each> + </properties> +</xsl:template> + +<xsl:template match="TestFunction"> + <testcase classname="{$classname}" name="{@name}" time="0.0"> + <!-- handle fail --> + <xsl:if test="Incident/@type = 'fail'"> + <!-- will be used to generate "nice" error message --> + <xsl:variable name="file" select="Incident/@file" /> + <xsl:variable name="line" select="Incident/@line" /> + <xsl:variable name="description"> + <xsl:value-of select="Incident/Description" /> + </xsl:variable> + + <!-- display a reasonable error message --> + <xsl:element name="failure"> + <xsl:attribute name="type">Standard</xsl:attribute> + <xsl:attribute name="message"> + <xsl:value-of select="concat($file,':',$line,' :: ',$description)" /> + </xsl:attribute> + </xsl:element> + + </xsl:if> + + <!-- handle skip --> + <xsl:if test="Incident/@type = 'skip'"> + + </xsl:if> + </testcase> +</xsl:template> + +<xsl:template name="display-system-out"> + <system-out> + <xsl:for-each select="/TestCase/TestFunction/Incident[@type='fail'] | /TestCase/TestFunction/Message[@type='skip']"> + <xsl:choose> + <xsl:when test="@type='fail'"> + <xsl:value-of select="Description"/> + </xsl:when> + <xsl:when test="@type='skip'"> + <xsl:value-of select="Description"/> + </xsl:when> + </xsl:choose> + </xsl:for-each> + </system-out> +</xsl:template> + +<xsl:template name="display-system-err"> + <!-- do nothing for now --> + <system-err /> +</xsl:template> + +</xsl:stylesheet> + |