summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-02-11 12:50:31 +0100
committerJan Holthuis <jan.holthuis@ruhr-uni-bochum.de>2020-02-11 12:51:05 +0100
commit191b6b674f9ccee4d6f517847d7c01fda56d78b9 (patch)
treec7e166dbc170b12722c263b3539df9162c5ae708 /cmake
parent23a236c4f9c0a4693b8aa87d8b0bbbf445ed068d (diff)
CMake: Add XSLT for converting from CTest results to JUnit XML
Diffstat (limited to 'cmake')
-rw-r--r--cmake/ctest-to-junit.xsl43
1 files changed, 43 insertions, 0 deletions
diff --git a/cmake/ctest-to-junit.xsl b/cmake/ctest-to-junit.xsl
new file mode 100644
index 0000000000..24ec730ffb
--- /dev/null
+++ b/cmake/ctest-to-junit.xsl
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+This XSLT stylesheet is taken from the jenkins-ctest-plugin by Version One,
+Inc. and Ryan Pavlik <abiryan@ryand.net> and is subject to the terms of the
+MIT License.
+
+It was taken from this GitHub repositiory:
+ https://github.com/rpavlik/jenkins-ctest-plugin
+-->
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ <xsl:output method="xml" indent="yes" />
+ <xsl:template match="/">
+ <testsuites>
+ <xsl:variable name="buildName" select="//Site/@BuildName"/>
+ <xsl:variable name="numberOfTests" select="count(//Site/Testing/Test)"/>
+ <xsl:variable name="numberOfFailures" select="count(//Site/Testing/Test[@Status!='passed'])" />
+ <testsuite name="CTest"
+ tests="{$numberOfTests}" time="0"
+ failures="{$numberOfFailures}" errors="0"
+ skipped="0">
+ <xsl:for-each select="//Site/Testing/Test">
+ <xsl:variable name="testName" select="translate(Name, '-', '_')"/>
+ <xsl:variable name="duration" select="Results/NamedMeasurement[@name='Execution Time']/Value"/>
+ <xsl:variable name="status" select="@Status"/>
+ <xsl:variable name="output" select="Results/Measurement/Value"/>
+ <xsl:variable name="className" select="translate(Path, '/.', '.')"/>
+ <testcase classname="projectroot{$className}"
+ name="{$testName}"
+ time="{$duration}">
+ <xsl:if test="@Status!='passed'">
+ <failure>
+ <xsl:value-of select="$output" />
+ </failure>
+ </xsl:if>
+ <system-out>
+ <xsl:value-of select="$output" />
+ </system-out>
+ </testcase>
+ </xsl:for-each>
+ </testsuite>
+ </testsuites>
+ </xsl:template>
+</xsl:stylesheet>