summaryrefslogtreecommitdiffstats
path: root/cmake/ctest-to-junit.xsl
blob: 8bd53978b6acddf5e53321948a68937c9474e6d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?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

Includes modifications by Jan Holthuis to add support for skipped/errored
tests.
-->
<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='failed'">
							<failure>
								<xsl:value-of select="$output" />
							</failure>
						</xsl:if>
						<xsl:if test="@Status='errored'">
							<error>
								<xsl:value-of select="$output" />
							</error>
						</xsl:if>
						<xsl:if test="@Status='notrun'">
							<skipped />
						</xsl:if>
						<system-out>
							<xsl:value-of select="$output" />
						</system-out>
					</testcase>
				</xsl:for-each>
			</testsuite>
		</testsuites>
	</xsl:template>
</xsl:stylesheet>