Skip to content

Commit ecb7b24

Browse files
committed
Added xslt for transforming CTest results to Junit for Jenkins. Source: https://gist.github.com/2358656
1 parent ddb972d commit ecb7b24

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

tests/ctest2junix.xsl

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
2+
<xsl:output method="xml" indent="yes"/>
3+
4+
<xsl:template match="/Site">
5+
<testsuite>
6+
<xsl:variable name="BuildName"><xsl:value-of select="@BuildName"/></xsl:variable>
7+
<xsl:variable name="BuildStamp"><xsl:value-of select="@BuildStamp"/></xsl:variable>
8+
<xsl:variable name="Name"><xsl:value-of select="@Name"/></xsl:variable>
9+
<xsl:variable name="Generator"><xsl:value-of select="@Generator"/></xsl:variable>
10+
<xsl:variable name="CompilerName"><xsl:value-of select="@CompilerName"/></xsl:variable>
11+
<xsl:variable name="OSName"><xsl:value-of select="@OSName"/></xsl:variable>
12+
<xsl:variable name="Hostname"><xsl:value-of select="@Hostname"/></xsl:variable>
13+
<xsl:variable name="OSRelease"><xsl:value-of select="@OSRelease"/></xsl:variable>
14+
<xsl:variable name="OSVersion"><xsl:value-of select="@OSVersion"/></xsl:variable>
15+
<xsl:variable name="OSPlatform"><xsl:value-of select="@OSPlatform"/></xsl:variable>
16+
<xsl:variable name="Is64Bits"><xsl:value-of select="@Is64Bits"/></xsl:variable>
17+
<xsl:variable name="VendorString"><xsl:value-of select="@VendorString"/></xsl:variable>
18+
<xsl:variable name="VendorID"><xsl:value-of select="@VendorID"/></xsl:variable>
19+
<xsl:variable name="FamilyID"><xsl:value-of select="@FamilyID"/></xsl:variable>
20+
<xsl:variable name="ModelID"><xsl:value-of select="@ModelID"/></xsl:variable>
21+
<xsl:variable name="ProcessorCacheSize"><xsl:value-of select="@ProcessorCacheSize"/></xsl:variable>
22+
<xsl:variable name="NumberOfLogicalCPU"><xsl:value-of select="@NumberOfLogicalCPU"/></xsl:variable>
23+
<xsl:variable name="NumberOfPhysicalCPU"><xsl:value-of select="@NumberOfPhysicalCPU"/></xsl:variable>
24+
<xsl:variable name="TotalVirtualMemory"><xsl:value-of select="@TotalVirtualMemory"/></xsl:variable>
25+
<xsl:variable name="TotalPhysicalMemory"><xsl:value-of select="@TotalPhysicalMemory"/></xsl:variable>
26+
<xsl:variable name="LogicalProcessorsPerPhysical"><xsl:value-of select="@LogicalProcessorsPerPhysical"/></xsl:variable>
27+
<xsl:variable name="ProcessorClockFrequency"><xsl:value-of select="@ProcessorClockFrequency"/></xsl:variable>
28+
<properties>
29+
<property name="BuildName" value="{$BuildName}" />
30+
<property name="BuildStamp" value="{$BuildStamp}" />
31+
<property name="Name" value="{$Name}" />
32+
<property name="Generator" value="{$Generator}" />
33+
<property name="CompilerName" value="{$CompilerName}" />
34+
<property name="OSName" value="{$OSName}" />
35+
<property name="Hostname" value="{$Hostname}" />
36+
<property name="OSRelease" value="{$OSRelease}" />
37+
<property name="OSVersion" value="{$OSVersion}" />
38+
<property name="OSPlatform" value="{$OSPlatform}" />
39+
<property name="Is64Bits" value="{$Is64Bits}" />
40+
<property name="VendorString" value="{$VendorString}" />
41+
<property name="VendorID" value="{$VendorID}" />
42+
<property name="FamilyID" value="{$FamilyID}" />
43+
<property name="ModelID" value="{$ModelID}" />
44+
<property name="ProcessorCacheSize" value="{$ProcessorCacheSize}" />
45+
<property name="NumberOfLogicalCPU" value="{$NumberOfLogicalCPU}" />
46+
<property name="NumberOfPhysicalCPU" value="{$NumberOfPhysicalCPU}" />
47+
<property name="TotalVirtualMemory" value="{$TotalVirtualMemory}" />
48+
<property name="TotalPhysicalMemory" value="{$TotalPhysicalMemory}" />
49+
<property name="LogicalProcessorsPerPhysical" value="{$LogicalProcessorsPerPhysical}" />
50+
<property name="ProcessorClockFrequency" value="{$ProcessorClockFrequency}" />
51+
</properties>
52+
<xsl:apply-templates select="Testing/Test"/>
53+
54+
<system-out>
55+
BuildName: <xsl:value-of select="$BuildName" />
56+
BuildStamp: <xsl:value-of select="$BuildStamp" />
57+
Name: <xsl:value-of select="$Name" />
58+
Generator: <xsl:value-of select="$Generator" />
59+
CompilerName: <xsl:value-of select="$CompilerName" />
60+
OSName: <xsl:value-of select="$OSName" />
61+
Hostname: <xsl:value-of select="$Hostname" />
62+
OSRelease: <xsl:value-of select="$OSRelease" />
63+
OSVersion: <xsl:value-of select="$OSVersion" />
64+
OSPlatform: <xsl:value-of select="$OSPlatform" />
65+
Is64Bits: <xsl:value-of select="$Is64Bits" />
66+
VendorString: <xsl:value-of select="$VendorString" />
67+
VendorID: <xsl:value-of select="$VendorID" />
68+
FamilyID: <xsl:value-of select="$FamilyID" />
69+
ModelID: <xsl:value-of select="$ModelID" />
70+
ProcessorCacheSize: <xsl:value-of select="$ProcessorCacheSize" />
71+
NumberOfLogicalCPU: <xsl:value-of select="$NumberOfLogicalCPU" />
72+
NumberOfPhysicalCPU: <xsl:value-of select="$NumberOfPhysicalCPU" />
73+
TotalVirtualMemory: <xsl:value-of select="$TotalVirtualMemory" />
74+
TotalPhysicalMemory: <xsl:value-of select="$TotalPhysicalMemory" />
75+
LogicalProcessorsPerPhysical: <xsl:value-of select="$LogicalProcessorsPerPhysical" />
76+
ProcessorClockFrequency: <xsl:value-of select="$ProcessorClockFrequency" />
77+
</system-out>
78+
</testsuite>
79+
</xsl:template>
80+
81+
<xsl:template match="Testing/Test">
82+
<xsl:variable name="testcasename"><xsl:value-of select= "Name"/></xsl:variable>
83+
<xsl:variable name="exectime">
84+
<xsl:for-each select="Results/NamedMeasurement">
85+
<xsl:if test="@name = 'Execution Time'">
86+
<xsl:value-of select="."/>
87+
</xsl:if>
88+
</xsl:for-each>
89+
</xsl:variable>
90+
91+
<testcase name="{$testcasename}" classname="TestSuite" time="{$exectime}">
92+
<xsl:if test="@Status = 'passed'">
93+
</xsl:if>
94+
<xsl:if test="@Status = 'failed'">
95+
<xsl:variable name="failtype">
96+
<xsl:for-each select="Results/NamedMeasurement">
97+
<xsl:if test="@name = 'Exit Code'">
98+
<xsl:value-of select="."/>
99+
</xsl:if>
100+
</xsl:for-each>
101+
</xsl:variable>
102+
<xsl:variable name="failcode">
103+
<xsl:for-each select="Results/NamedMeasurement">
104+
<xsl:if test="@name = 'Exit Value'">
105+
<xsl:value-of select="."/>
106+
</xsl:if>
107+
</xsl:for-each>
108+
</xsl:variable>
109+
<error message="{$failtype} ({$failcode})"><xsl:value-of select="Results/Measurement/Value/text()" /></error>
110+
</xsl:if>
111+
<xsl:if test="@Status = 'notrun'">
112+
<skipped><xsl:value-of select="Results/Measurement/Value/text()" /></skipped>
113+
</xsl:if>
114+
<system-out><xsl:value-of select="Results/Measurement/Value/text()" /></system-out>
115+
</testcase>
116+
</xsl:template>
117+
118+
</xsl:stylesheet>
119+

0 commit comments

Comments
 (0)