11<?xml version =" 1.0" encoding =" UTF-8" ?>
22<!--
3- /*******************************************************************************
4- * Copyright (c) 2011 Thales Corporate Services SAS *
5- * Author : Gregory Boissinot, Aravindan Mahendran *
6- * *
7- * Permission is hereby granted, free of charge, to any person obtaining a copy *
8- * of this software and associated documentation files (the "Software"), to deal*
9- * in the Software without restriction, including without limitation the rights *
10- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell *
11- * copies of the Software, and to permit persons to whom the Software is *
12- * furnished to do so, subject to the following conditions: *
13- * *
14- * The above copyright notice and this permission notice shall be included in *
15- * all copies or substantial portions of the Software. *
16- * *
17- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
18- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *
19- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
20- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
21- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,*
22- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN *
23- * THE SOFTWARE. *
24- *******************************************************************************/
3+ The MIT License (MIT)
4+
5+ Copyright (c) 2011, Gregory Boissinot, Aravindan Mahendran
6+
7+ Permission is hereby granted, free of charge, to any person obtaining a copy
8+ of this software and associated documentation files (the "Software"), to deal
9+ in the Software without restriction, including without limitation the rights
10+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+ copies of the Software, and to permit persons to whom the Software is
12+ furnished to do so, subject to the following conditions:
13+
14+ The above copyright notice and this permission notice shall be included in
15+ all copies or substantial portions of the Software.
16+
17+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23+ THE SOFTWARE.
2524-->
26- <xsl : stylesheet version =" 2.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform" >
25+ <xsl : stylesheet version =" 2.0" xmlns : xsl =" http://www.w3.org/1999/XSL/Transform" xmlns : xs =" http://www.w3.org/2001/XMLSchema" xmlns : xunit =" http://www.xunit.org" >
26+ <xsl : output method =" xml" indent =" yes" encoding =" UTF-8" cdata-section-elements =" system-out system-err failure" />
27+ <xsl : decimal-format decimal-separator =" ." grouping-separator =" ," />
2728
28- <xsl : output method =" xml" encoding =" UTF-8" indent =" yes" />
29+ <xsl : function name =" xunit:junit-time" as =" xs:string" >
30+ <xsl : param name =" value" as =" xs:double?" />
31+
32+ <xsl : variable name =" time" as =" xs:double" >
33+ <xsl : value-of select =" translate(string($value),',','.')" />
34+ </xsl : variable >
35+ <xsl : value-of select =" format-number($time, '0.000')" />
36+ </xsl : function >
37+
38+ <xsl : function name =" xunit:millis-from-time" as =" xs:double" >
39+ <xsl : param name =" value" as =" xs:string?" />
40+
41+ <xsl : variable name =" formattedTime" select =" xunit:if-empty(replace(translate($value,',','.'), '^(\d:.+)', '0$1'), '00:00:00')" />
42+ <xsl : variable name =" time" select =" xs:time($formattedTime)" />
43+ <xsl : value-of select =" hours-from-time($time)*3600 + minutes-from-time($time)*60 + seconds-from-time($time)" />
44+ </xsl : function >
45+
46+ <xsl : function name =" xunit:if-empty" as =" xs:string" >
47+ <xsl : param name =" value" as =" xs:string?" />
48+ <xsl : param name =" default" as =" xs:anyAtomicType?" />
49+ <xsl : value-of select =" if (string($value) != '') then string($value) else $default" />
50+ </xsl : function >
51+
52+ <xsl : function name =" xunit:is-empty" as =" xs:boolean" >
53+ <xsl : param name =" value" as =" xs:string?" />
54+ <xsl : value-of select =" string($value) != ''" />
55+ </xsl : function >
2956
3057 <xsl : template match =" /" >
31- <testsuite name =" {ResultsSession/Exec/Summary/Projects/Project/@name}" time =" 0"
32- tests =" {Summary/Projects/Project/@testCases}"
33- failures =" {ResultsSession/Exec/Summary/Projects/Project/@fail}" >
34- <xsl : apply-templates select =" ResultsSession/Exec" ></xsl : apply-templates >
35- <xsl : apply-templates select =" ResultsSession/ExecutedTestsDetails" ></xsl : apply-templates >
36- </testsuite >
58+ <xsl : variable name =" testCount" select =" ResultsSession/Exec/Summary/Projects/Project/@testCases" />
59+ <xsl : variable name =" failureCount" select =" ResultsSession/Exec/Summary/Projects/Project/@fail" />
60+ <xsl : variable name =" suiteName" select =" ResultsSession/Exec/Summary/Projects/Project/@name" />
61+ <xsl : variable name =" totalTime" select =" xunit:junit-time(xunit:millis-from-time(ResultsSession/Exec/@time))" />
62+
63+ <xsl : choose >
64+ <xsl : when test =" ResultsSession/Exec/TestingProcessProblems" >
65+ <!-- No tests was run -->
66+ <testsuite name =" {ResultsSession/TestConfig/@name}"
67+ time =" {$totalTime}"
68+ tests =" 0"
69+ failures =" 0" >
70+ <xsl : element name =" system-err" >
71+ <xsl : value-of select =" ResultsSession/Exec/TestingProcessProblems/CppAnalysisProblem/ErrorList/Error/@val" />
72+ </xsl : element >
73+ </testsuite >
74+ </xsl : when >
75+ <xsl : when test =" ResultsSession/ExecutedTestsDetails" >
76+ <!-- CppTest 9.x -->
77+ <testsuites name =" {$suiteName}"
78+ time =" {$totalTime}"
79+ tests =" {$testCount}"
80+ failures =" {$failureCount}" >
81+ <xsl : apply-templates select =" ResultsSession/ExecutedTestsDetails/Total/Project/TestSuite" >
82+ <xsl : with-param name =" suiteName" select =" $suiteName" />
83+ </xsl : apply-templates >
84+ </testsuites >
85+ </xsl : when >
86+ <xsl : otherwise >
87+ <!-- CppTest 7.x -->
88+ <testsuite name =" {$suiteName}"
89+ time =" {$totalTime}"
90+ tests =" {$testCount}"
91+ failures =" {$failureCount}" >
92+ <xsl : call-template name =" TestCase_7x" >
93+ <xsl : with-param name =" violations" select =" ResultsSession/Exec/ExecViols" />
94+ </xsl : call-template >
95+ </testsuite >
96+ </xsl : otherwise >
97+ </xsl : choose >
3798 </xsl : template >
3899
39- <xsl : template match =" Exec" >
40- <xsl : apply-templates select =" *" />
41- </xsl : template >
100+ <xsl : template name =" TestCase_7x" >
101+ <xsl : param name =" violations" />
42102
43- <xsl : template match =" Goals" >
44- <properties >
45- <xsl : apply-templates select =" Goal" />
46- </properties >
103+ <xsl : for-each select =" $violations/ExecViol" >
104+ <xsl : variable name =" suiteName" select =" substring-before(@testName, '::')" />
105+ <xsl : variable name =" testName" select =" substring-after(@testName, '::')" />
106+
107+ <testcase classname =" {$suiteName}" name =" {$testName}" time =" {xunit:junit-time(0)}" >
108+ <xsl : apply-templates select =" Thr" />
109+ </testcase >
110+ </xsl : for-each >
47111 </xsl : template >
48112
49- <xsl : template match =" Goal" >
50- <property name =" {@name}" value =" {@type}" />
113+ <xsl : template match =" TestSuite" >
114+ <xsl : param name =" suiteName" as =" xs:string?" />
115+
116+ <xsl : variable name =" suiteName" select =" concat($suiteName, '.', @name)" />
117+ <xsl : choose >
118+ <xsl : when test =" count(TestSuite) > 0" >
119+ <xsl : apply-templates select =" TestSuite" >
120+ <xsl : with-param name =" suiteName" select =" $suiteName" />
121+ </xsl : apply-templates >
122+ </xsl : when >
123+ <xsl : otherwise >
124+ <testsuite name =" {$suiteName}"
125+ time =" {xunit:junit-time(0)}"
126+ tests =" {@pass + @fail}"
127+ failures =" {@fail}" >
128+ <xsl : apply-templates select =" Test" >
129+ <xsl : with-param name =" fullSuiteName" select =" $suiteName" />
130+ <xsl : with-param name =" suiteName" select =" @name" />
131+ </xsl : apply-templates >
132+ </testsuite >
133+ </xsl : otherwise >
134+ </xsl : choose >
51135 </xsl : template >
52136
53- <xsl : template match =" ExecViols" >
54- <xsl : apply-templates select =" ExecViol" />
137+ <xsl : template match =" Test" >
138+ <xsl : param name =" suiteName" as =" xs:string?" />
139+ <xsl : param name =" fullSuiteName" as =" xs:string?" />
140+
141+ <xsl : variable name =" testName" select =" if (starts-with(@name, $suiteName)) then substring(@name, string-length($suiteName) + 3) else @name" />
142+ <xsl : variable name =" testId" select =" @id" />
143+ <testcase name =" {$testName}"
144+ classname =" {xunit:if-empty($fullSuiteName, $suiteName)}"
145+ time =" {xunit:junit-time(xunit:millis-from-time(@time))}" >
146+ <xsl : if test =" @pass != 1" >
147+ <xsl : apply-templates select =" //Exec/ExecViols/ExecViol[@testId = $testId]" />
148+ </xsl : if >
149+ </testcase >
55150 </xsl : template >
56151
57152 <xsl : template match =" ExecViol" >
58- <xsl : if test =" @cat!=6" >
59- <testcase classname =" {@locFile}" name =" {@testName}" time =" 0" >
60- <xsl : apply-templates select =" Thr" />
61- </testcase >
62- </xsl : if >
153+ <xsl : apply-templates select =" Thr" />
63154 </xsl : template >
64155
65156 <xsl : template match =" Thr" >
66157 <xsl : apply-templates select =" ThrPart" />
67158 </xsl : template >
68159
69160 <xsl : template match =" ThrPart" >
70- <failure type =" {@clName}" message =" {@detMsg}" />
71- <system-err >
72- <xsl : text >Trace </xsl : text >
161+ <failure type =" {@clName}" message =" {@detMsg}" >
73162 <xsl : apply-templates select =" Trace" />
74- </system-err >
163+ </failure >
75164 </xsl : template >
76165
77166 <xsl : template match =" Trace" >
78- <xsl : text >Line :</xsl : text >
79- <xsl : value-of select =" @ln" />
80- <xsl : text > File :</xsl : text >
81- <xsl : value-of select =" @fileName" />
82- </xsl : template >
83-
84- <xsl : template match =" ExecutedTestsDetails" >
85- <xsl : apply-templates select =" Total" />
86- </xsl : template >
87-
88- <xsl : template match =" Total" >
89- <xsl : apply-templates select =" Project" />
90- </xsl : template >
91-
92- <xsl : template match =" Project" >
93- <xsl : apply-templates select =" TestSuite" />
94- </xsl : template >
95-
96- <xsl : template match =" TestSuite" >
97- <xsl : apply-templates select =" *" />
98- </xsl : template >
99-
100- <xsl : template match =" Test" >
101- <xsl : variable name =" fullTestName" ><xsl : value-of select =" /ResultsSession/Exec/Summary/Projects/Project/@name" />JUnitTestSuite
102- </xsl : variable >
103- <xsl : if test =" @pass=1" >
104- <testcase name =" {@name}" classname =" {$fullTestName}" time =" 0" />
105- </xsl : if >
167+ at <xsl : value-of select =" @fileName" />:<xsl : value-of select =" @ln" />
106168 </xsl : template >
107169
108170</xsl : stylesheet >
0 commit comments