source: local/greenstone3/darwin-64bit/apache-ant-1.9.6/etc/junit-noframes.xsl@ 30383

Last change on this file since 30383 was 30383, checked in by davidb, 8 years ago

Newer version of ant needed to compile GS3

File size: 19.9 KB
Line 
1<?xml version="1.0"?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
3 xmlns:lxslt="http://xml.apache.org/xslt"
4 xmlns:string="xalan://java.lang.String">
5<xsl:output method="html" indent="yes" encoding="UTF-8"
6 doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN" />
7<xsl:decimal-format decimal-separator="." grouping-separator="," />
8<!--
9 Licensed to the Apache Software Foundation (ASF) under one or more
10 contributor license agreements. See the NOTICE file distributed with
11 this work for additional information regarding copyright ownership.
12 The ASF licenses this file to You under the Apache License, Version 2.0
13 (the "License"); you may not use this file except in compliance with
14 the License. You may obtain a copy of the License at
15
16 http://www.apache.org/licenses/LICENSE-2.0
17
18 Unless required by applicable law or agreed to in writing, software
19 distributed under the License is distributed on an "AS IS" BASIS,
20 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 See the License for the specific language governing permissions and
22 limitations under the License.
23 -->
24
25<xsl:param name="TITLE">Unit Test Results.</xsl:param>
26
27<!--
28
29 Sample stylesheet to be used with Ant JUnitReport output.
30
31 It creates a non-framed report that can be useful to send via
32 e-mail or such.
33
34-->
35<xsl:template match="testsuites">
36 <html>
37 <head>
38 <title><xsl:value-of select="$TITLE"/></title>
39 <style type="text/css">
40 body {
41 font:normal 68% verdana,arial,helvetica;
42 color:#000000;
43 }
44 table tr td, table tr th {
45 font-size: 68%;
46 }
47 table.details tr th{
48 font-weight: bold;
49 text-align:left;
50 background:#a6caf0;
51 }
52 table.details tr td{
53 background:#eeeee0;
54 }
55
56 p {
57 line-height:1.5em;
58 margin-top:0.5em; margin-bottom:1.0em;
59 }
60 h1 {
61 margin: 0px 0px 5px; font: 165% verdana,arial,helvetica
62 }
63 h2 {
64 margin-top: 1em; margin-bottom: 0.5em; font: bold 125% verdana,arial,helvetica
65 }
66 h3 {
67 margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica
68 }
69 h4 {
70 margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
71 }
72 h5 {
73 margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
74 }
75 h6 {
76 margin-bottom: 0.5em; font: bold 100% verdana,arial,helvetica
77 }
78 .Error {
79 font-weight:bold; color:red;
80 }
81 .Failure {
82 font-weight:bold; color:purple;
83 }
84 .Properties {
85 text-align:right;
86 }
87 </style>
88 <script type="text/javascript" language="JavaScript">
89 var TestCases = new Array();
90 var cur;
91 <xsl:for-each select="./testsuite">
92 <xsl:apply-templates select="properties"/>
93 </xsl:for-each>
94
95 </script>
96 <script type="text/javascript" language="JavaScript"><![CDATA[
97 function displayProperties (name) {
98 var win = window.open('','JUnitSystemProperties','scrollbars=1,resizable=1');
99 var doc = win.document;
100 doc.open();
101 doc.write("<html><head><title>Properties of " + name + "</title>");
102 doc.write("<style>")
103 doc.write("body {font:normal 68% verdana,arial,helvetica; color:#000000; }");
104 doc.write("table tr td, table tr th { font-size: 68%; }");
105 doc.write("table.properties { border-collapse:collapse; border-left:solid 1 #cccccc; border-top:solid 1 #cccccc; padding:5px; }");
106 doc.write("table.properties th { text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#eeeeee; }");
107 doc.write("table.properties td { font:normal; text-align:left; border-right:solid 1 #cccccc; border-bottom:solid 1 #cccccc; background-color:#fffffff; }");
108 doc.write("h3 { margin-bottom: 0.5em; font: bold 115% verdana,arial,helvetica }");
109 doc.write("</style>");
110 doc.write("</head><body>");
111 doc.write("<h3>Properties of " + name + "</h3>");
112 doc.write("<div align=\"right\"><a href=\"javascript:window.close();\">Close</a></div>");
113 doc.write("<table class='properties'>");
114 doc.write("<tr><th>Name</th><th>Value</th></tr>");
115 for (prop in TestCases[name]) {
116 doc.write("<tr><th>" + prop + "</th><td>" + TestCases[name][prop] + "</td></tr>");
117 }
118 doc.write("</table>");
119 doc.write("</body></html>");
120 doc.close();
121 win.focus();
122 }
123 ]]>
124 </script>
125 </head>
126 <body>
127 <a name="top"></a>
128 <xsl:call-template name="pageHeader"/>
129
130 <!-- Summary part -->
131 <xsl:call-template name="summary"/>
132 <hr size="1" width="95%" align="left"/>
133
134 <!-- Package List part -->
135 <xsl:call-template name="packagelist"/>
136 <hr size="1" width="95%" align="left"/>
137
138 <!-- For each package create its part -->
139 <xsl:call-template name="packages"/>
140 <hr size="1" width="95%" align="left"/>
141
142 <!-- For each class create the part -->
143 <xsl:call-template name="classes"/>
144
145 </body>
146 </html>
147</xsl:template>
148
149
150
151 <!-- ================================================================== -->
152 <!-- Write a list of all packages with an hyperlink to the anchor of -->
153 <!-- of the package name. -->
154 <!-- ================================================================== -->
155 <xsl:template name="packagelist">
156 <h2>Packages</h2>
157 Note: package statistics are not computed recursively, they only sum up all of its testsuites numbers.
158 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
159 <xsl:call-template name="testsuite.test.header"/>
160 <!-- list all packages recursively -->
161 <xsl:for-each select="./testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
162 <xsl:sort select="@package"/>
163 <xsl:variable name="testsuites-in-package" select="/testsuites/testsuite[./@package = current()/@package]"/>
164 <xsl:variable name="testCount" select="sum($testsuites-in-package/@tests)"/>
165 <xsl:variable name="errorCount" select="sum($testsuites-in-package/@errors)"/>
166 <xsl:variable name="failureCount" select="sum($testsuites-in-package/@failures)"/>
167 <xsl:variable name="skippedCount" select="sum($testsuites-in-package/@skipped)" />
168 <xsl:variable name="timeCount" select="sum($testsuites-in-package/@time)"/>
169
170 <!-- write a summary for the package -->
171 <tr valign="top">
172 <!-- set a nice color depending if there is an error/failure -->
173 <xsl:attribute name="class">
174 <xsl:choose>
175 <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
176 <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
177 </xsl:choose>
178 </xsl:attribute>
179 <td><a href="#{@package}"><xsl:value-of select="@package"/></a></td>
180 <td><xsl:value-of select="$testCount"/></td>
181 <td><xsl:value-of select="$errorCount"/></td>
182 <td><xsl:value-of select="$failureCount"/></td>
183 <td><xsl:value-of select="$skippedCount" /></td>
184 <td>
185 <xsl:call-template name="display-time">
186 <xsl:with-param name="value" select="$timeCount"/>
187 </xsl:call-template>
188 </td>
189 <td><xsl:value-of select="$testsuites-in-package/@timestamp"/></td>
190 <td><xsl:value-of select="$testsuites-in-package/@hostname"/></td>
191 </tr>
192 </xsl:for-each>
193 </table>
194 </xsl:template>
195
196
197 <!-- ================================================================== -->
198 <!-- Write a package level report -->
199 <!-- It creates a table with values from the document: -->
200 <!-- Name | Tests | Errors | Failures | Time -->
201 <!-- ================================================================== -->
202 <xsl:template name="packages">
203 <!-- create an anchor to this package name -->
204 <xsl:for-each select="/testsuites/testsuite[not(./@package = preceding-sibling::testsuite/@package)]">
205 <xsl:sort select="@package"/>
206 <a name="{@package}"></a>
207 <h3>Package <xsl:value-of select="@package"/></h3>
208
209 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
210 <xsl:call-template name="testsuite.test.header"/>
211
212 <!-- match the testsuites of this package -->
213 <xsl:apply-templates select="/testsuites/testsuite[./@package = current()/@package]" mode="print.test"/>
214 </table>
215 <a href="#top">Back to top</a>
216 <p/>
217 <p/>
218 </xsl:for-each>
219 </xsl:template>
220
221 <xsl:template name="classes">
222 <xsl:for-each select="testsuite">
223 <xsl:sort select="@name"/>
224 <!-- create an anchor to this class name -->
225 <a name="{@name}"></a>
226 <h3>TestCase <xsl:value-of select="@name"/></h3>
227
228 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
229 <xsl:call-template name="testcase.test.header"/>
230 <!--
231 test can even not be started at all (failure to load the class)
232 so report the error directly
233 -->
234 <xsl:if test="./error">
235 <tr class="Error">
236 <td colspan="4"><xsl:apply-templates select="./error"/></td>
237 </tr>
238 </xsl:if>
239 <xsl:apply-templates select="./testcase" mode="print.test"/>
240 </table>
241 <div class="Properties">
242 <a>
243 <xsl:attribute name="href">javascript:displayProperties('<xsl:value-of select="@package"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
244 Properties &#187;
245 </a>
246 </div>
247 <p/>
248
249 <a href="#top">Back to top</a>
250 </xsl:for-each>
251 </xsl:template>
252
253 <xsl:template name="summary">
254 <h2>Summary</h2>
255 <xsl:variable name="testCount" select="sum(testsuite/@tests)"/>
256 <xsl:variable name="errorCount" select="sum(testsuite/@errors)"/>
257 <xsl:variable name="failureCount" select="sum(testsuite/@failures)"/>
258 <xsl:variable name="skippedCount" select="sum(testsuite/@skipped)" />
259 <xsl:variable name="timeCount" select="sum(testsuite/@time)"/>
260 <xsl:variable name="successRate" select="($testCount - $failureCount - $errorCount) div $testCount"/>
261 <table class="details" border="0" cellpadding="5" cellspacing="2" width="95%">
262 <tr valign="top">
263 <th>Tests</th>
264 <th>Failures</th>
265 <th>Errors</th>
266 <th>Skipped</th>
267 <th>Success rate</th>
268 <th>Time</th>
269 </tr>
270 <tr valign="top">
271 <xsl:attribute name="class">
272 <xsl:choose>
273 <xsl:when test="$failureCount &gt; 0">Failure</xsl:when>
274 <xsl:when test="$errorCount &gt; 0">Error</xsl:when>
275 </xsl:choose>
276 </xsl:attribute>
277 <td><xsl:value-of select="$testCount"/></td>
278 <td><xsl:value-of select="$failureCount"/></td>
279 <td><xsl:value-of select="$errorCount"/></td>
280 <td><xsl:value-of select="$skippedCount" /></td>
281 <td>
282 <xsl:call-template name="display-percent">
283 <xsl:with-param name="value" select="$successRate"/>
284 </xsl:call-template>
285 </td>
286 <td>
287 <xsl:call-template name="display-time">
288 <xsl:with-param name="value" select="$timeCount"/>
289 </xsl:call-template>
290 </td>
291
292 </tr>
293 </table>
294 <table border="0" width="95%">
295 <tr>
296 <td style="text-align: justify;">
297 Note: <i>failures</i> are anticipated and checked for with assertions while <i>errors</i> are unanticipated.
298 </td>
299 </tr>
300 </table>
301 </xsl:template>
302
303 <!--
304 Write properties into a JavaScript data structure.
305 This is based on the original idea by Erik Hatcher ([email protected])
306 -->
307 <xsl:template match="properties">
308 cur = TestCases['<xsl:value-of select="../@package"/>.<xsl:value-of select="../@name"/>'] = new Array();
309 <xsl:for-each select="property">
310 <xsl:sort select="@name"/>
311 cur['<xsl:value-of select="@name"/>'] = '<xsl:call-template name="JS-escape"><xsl:with-param name="string" select="@value"/></xsl:call-template>';
312 </xsl:for-each>
313 </xsl:template>
314
315<!-- Page HEADER -->
316<xsl:template name="pageHeader">
317 <h1><xsl:value-of select="$TITLE"/></h1>
318 <table width="100%">
319 <tr>
320 <td align="left"></td>
321 <td align="right">Designed for use with <a href='http://www.junit.org'>JUnit</a> and <a href='http://ant.apache.org/ant'>Ant</a>.</td>
322 </tr>
323 </table>
324 <hr size="1"/>
325</xsl:template>
326
327<xsl:template match="testsuite" mode="header">
328 <tr valign="top">
329 <th width="80%">Name</th>
330 <th>Tests</th>
331 <th>Errors</th>
332 <th>Failures</th>
333 <th>Skipped</th>
334 <th nowrap="nowrap">Time(s)</th>
335 </tr>
336</xsl:template>
337
338<!-- class header -->
339<xsl:template name="testsuite.test.header">
340 <tr valign="top">
341 <th width="80%">Name</th>
342 <th>Tests</th>
343 <th>Errors</th>
344 <th>Failures</th>
345 <th>Skipped</th>
346 <th nowrap="nowrap">Time(s)</th>
347 <th nowrap="nowrap">Time Stamp</th>
348 <th>Host</th>
349 </tr>
350</xsl:template>
351
352<!-- method header -->
353<xsl:template name="testcase.test.header">
354 <tr valign="top">
355 <th>Name</th>
356 <th>Status</th>
357 <th width="80%">Type</th>
358 <th nowrap="nowrap">Time(s)</th>
359 </tr>
360</xsl:template>
361
362
363<!-- class information -->
364<xsl:template match="testsuite" mode="print.test">
365 <tr valign="top">
366 <!-- set a nice color depending if there is an error/failure -->
367 <xsl:attribute name="class">
368 <xsl:choose>
369 <xsl:when test="@failures[.&gt; 0]">Failure</xsl:when>
370 <xsl:when test="@errors[.&gt; 0]">Error</xsl:when>
371 </xsl:choose>
372 </xsl:attribute>
373
374 <!-- print testsuite information -->
375 <td><a href="#{@name}"><xsl:value-of select="@name"/></a></td>
376 <td><xsl:value-of select="@tests"/></td>
377 <td><xsl:value-of select="@errors"/></td>
378 <td><xsl:value-of select="@failures"/></td>
379 <td><xsl:value-of select="@skipped" /></td>
380 <td>
381 <xsl:call-template name="display-time">
382 <xsl:with-param name="value" select="@time"/>
383 </xsl:call-template>
384 </td>
385 <td><xsl:apply-templates select="@timestamp"/></td>
386 <td><xsl:apply-templates select="@hostname"/></td>
387 </tr>
388</xsl:template>
389
390<xsl:template match="testcase" mode="print.test">
391 <tr valign="top">
392 <xsl:attribute name="class">
393 <xsl:choose>
394 <xsl:when test="failure | error">Error</xsl:when>
395 </xsl:choose>
396 </xsl:attribute>
397 <td><xsl:value-of select="@name"/></td>
398 <xsl:choose>
399 <xsl:when test="failure">
400 <td>Failure</td>
401 <td><xsl:apply-templates select="failure"/></td>
402 </xsl:when>
403 <xsl:when test="error">
404 <td>Error</td>
405 <td><xsl:apply-templates select="error"/></td>
406 </xsl:when>
407 <xsl:when test="skipped">
408 <td>Skipped</td>
409 <td><xsl:apply-templates select="skipped"/></td>
410 </xsl:when>
411 <xsl:otherwise>
412 <td>Success</td>
413 <td></td>
414 </xsl:otherwise>
415 </xsl:choose>
416 <td>
417 <xsl:call-template name="display-time">
418 <xsl:with-param name="value" select="@time"/>
419 </xsl:call-template>
420 </td>
421 </tr>
422</xsl:template>
423
424
425<xsl:template match="failure">
426 <xsl:call-template name="display-failures"/>
427</xsl:template>
428
429<xsl:template match="error">
430 <xsl:call-template name="display-failures"/>
431</xsl:template>
432
433<xsl:template match="skipped">
434 <xsl:call-template name="display-failures"/>
435</xsl:template>
436
437<!-- Style for the error, failure and skipped in the testcase template -->
438<xsl:template name="display-failures">
439 <xsl:choose>
440 <xsl:when test="not(@message)">N/A</xsl:when>
441 <xsl:otherwise>
442 <xsl:value-of select="@message"/>
443 </xsl:otherwise>
444 </xsl:choose>
445 <!-- display the stacktrace -->
446 <code>
447 <br/><br/>
448 <xsl:call-template name="br-replace">
449 <xsl:with-param name="word" select="."/>
450 </xsl:call-template>
451 </code>
452 <!-- the later is better but might be problematic for non-21" monitors... -->
453 <!--pre><xsl:value-of select="."/></pre-->
454</xsl:template>
455
456<xsl:template name="JS-escape">
457 <xsl:param name="string"/>
458 <xsl:param name="tmp1" select="string:replaceAll(string:new(string($string)),'\\','\\\\')"/>
459 <xsl:param name="tmp2" select="string:replaceAll(string:new(string($tmp1)),&quot;'&quot;,&quot;\\&apos;&quot;)"/>
460 <xsl:param name="tmp3" select="string:replaceAll(string:new(string($tmp2)),&quot;&#10;&quot;,'\\n')"/>
461 <xsl:param name="tmp4" select="string:replaceAll(string:new(string($tmp3)),&quot;&#13;&quot;,'\\r')"/>
462 <xsl:value-of select="$tmp4"/>
463</xsl:template>
464
465
466<!--
467 template that will convert a carriage return into a br tag
468 @param word the text from which to convert CR to BR tag
469-->
470<xsl:template name="br-replace">
471 <xsl:param name="word"/>
472 <xsl:param name="splitlimit">32</xsl:param>
473 <xsl:variable name="secondhalflen" select="(string-length($word)+(string-length($word) mod 2)) div 2"/>
474 <xsl:variable name="secondhalfword" select="substring($word, $secondhalflen)"/>
475 <!-- When word is very big, a recursive replace is very heap/stack expensive, so subdivide on line break after middle of string -->
476 <xsl:choose>
477 <xsl:when test="(string-length($word) > $splitlimit) and (contains($secondhalfword, '&#xa;'))">
478 <xsl:variable name="secondhalfend" select="substring-after($secondhalfword, '&#xa;')"/>
479 <xsl:variable name="firsthalflen" select="string-length($word) - $secondhalflen"/>
480 <xsl:variable name="firsthalfword" select="substring($word, 1, $firsthalflen)"/>
481 <xsl:variable name="firsthalfend" select="substring-before($secondhalfword, '&#xa;')"/>
482 <xsl:call-template name="br-replace">
483 <xsl:with-param name="word" select="concat($firsthalfword,$firsthalfend)"/>
484 </xsl:call-template>
485 <br/>
486 <xsl:call-template name="br-replace">
487 <xsl:with-param name="word" select="$secondhalfend"/>
488 </xsl:call-template>
489 </xsl:when>
490 <xsl:when test="contains($word, '&#xa;')">
491 <xsl:value-of select="substring-before($word, '&#xa;')"/>
492 <br/>
493 <xsl:call-template name="br-replace">
494 <xsl:with-param name="word" select="substring-after($word, '&#xa;')"/>
495 </xsl:call-template>
496 </xsl:when>
497 <xsl:otherwise>
498 <xsl:value-of select="$word"/>
499 </xsl:otherwise>
500 </xsl:choose>
501</xsl:template>
502
503<xsl:template name="display-time">
504 <xsl:param name="value"/>
505 <xsl:value-of select="format-number($value,'0.000')"/>
506</xsl:template>
507
508<xsl:template name="display-percent">
509 <xsl:param name="value"/>
510 <xsl:value-of select="format-number($value,'0.00%')"/>
511</xsl:template>
512
513</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.