-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBaseScanner.xsl
412 lines (375 loc) · 15 KB
/
BaseScanner.xsl
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:redirect="org.apache.xalan.lib.Redirect"
extension-element-prefixes="redirect"
version="1.0">
<!-- FileName: BaseScanner.xsl -->
<!-- Author: [email protected] -->
<!-- Purpose: Base stylesheet for org.apache.qetest.XMLFileLogger
logFiles that defines the structure of test output reports.
Designed to be 'subclassed' by import/include and defining
custom output for your desired elements.
-->
<xsl:output method="html"
doctype-public="-//W3C//DTD HTML 4.0 Transitional"/>
<lxslt:component prefix="redirect" elements="write open close" functions="">
<lxslt:script lang="javaclass" src="org.apache.xalan.lib.Redirect"/>
</lxslt:component>
<!-- Include constant definitions for results file elements,
attributes, and values, copied from relevant Java code -->
<xsl:include href="resultsConstants.xsl"/>
<!-- Name of file for mini-fails redirected output -->
<xsl:param name="redirectFilename">BaseScannerMini.html</xsl:param>
<!-- ================================== -->
<!-- Root template: just define the structure of the output.
Allow subclasses to provide templates for each part.
-->
<xsl:template match="resultsfile">
<html>
<head>
<title><xsl:text>Test Results file: </xsl:text><xsl:value-of select="@logFile"/></title>
</head>
<body>
<p align="center" font="-2">
<xsl:text>Original results.xml: </xsl:text>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@logFile"/></xsl:attribute>
<xsl:value-of select="@logFile"/>
</xsl:element>
<xsl:text> Processing stylesheet: </xsl:text>
<xsl:call-template name="printScannerName"/>
</p>
<!-- Handle each individual testfile (i.e. TestName.java) that ran. -->
<xsl:apply-templates select="testfile"/>
</body>
</html>
</xsl:template>
<xsl:template name="printScannerName">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:text>BaseScanner.xsl</xsl:text></xsl:attribute>
<xsl:text>BaseScanner</xsl:text>
</xsl:element>
</xsl:template>
<xsl:template match="testfile">
<!-- Output any header info, like overall results summary -->
<xsl:call-template name="test-header"/>
<!-- Output detail results from testcases, etc. -->
<xsl:call-template name="test-body"/>
<!-- Output any footer info, like environment hashes, etc. -->
<xsl:call-template name="test-footer"/>
</xsl:template>
<!-- ================================== -->
<!-- Structural templates: each named template is normally called
from the root template of / to perform it's part.
-->
<!-- Output any header info, like overall results summary -->
<xsl:template name="test-header">
<table frame="box" border="1" rules="groups"
cellspacing="2" cellpadding="2"
bgcolor="#FFFFEE">
<caption>
<b><xsl:value-of select="@filename"/><xsl:text>: </xsl:text></b><xsl:value-of select="@desc"/>
</caption>
<redirect:write select="$redirectFilename" append="true">
<hr/>
<h3><xsl:value-of select="@filename"/>
<xsl:text>: </xsl:text><xsl:value-of select="@desc"/>
<xsl:text> in </xsl:text><xsl:value-of select="../@logFile"/>
</h3>
</redirect:write>
<!-- Print out mini-summary of overall results -->
<tr>
<td width="20%"><xsl:text>Overall (TestCases/TestPoints)</xsl:text></td>
<td>
<xsl:text>Pass: </xsl:text>
<xsl:value-of select="statistic[@desc='passCount[CASES]']/longval"/><xsl:text>/</xsl:text>
<xsl:value-of select="statistic[@desc='passCount[CHECKS]']/longval"/><xsl:text>, </xsl:text>
<xsl:text>Fail: </xsl:text>
<xsl:value-of select="statistic[@desc='failCount[CASES]']/longval"/><xsl:text>/</xsl:text>
<xsl:value-of select="statistic[@desc='failCount[CHECKS]']/longval"/><xsl:text>, </xsl:text>
<xsl:text>Errr: </xsl:text>
<xsl:value-of select="statistic[@desc='errrCount[CASES]']/longval"/><xsl:text>/</xsl:text>
<xsl:value-of select="statistic[@desc='errrCount[CHECKS]']/longval"/><xsl:text>, </xsl:text>
<xsl:text>Ambg: </xsl:text>
<xsl:value-of select="statistic[@desc='ambgCount[CASES]']/longval"/><xsl:text>/</xsl:text>
<xsl:value-of select="statistic[@desc='ambgCount[CHECKS]']/longval"/><xsl:text>, </xsl:text>
<xsl:text>Incp: </xsl:text>
<xsl:value-of select="statistic[@desc='incpCount[CASES]']/longval"/>
</td>
</tr>
<tr>
<td>
<xsl:text>Testcases</xsl:text>
</td>
<td>
<!-- Create links to non-passing testcases for easy navigation -->
<xsl:text>Fails: </xsl:text>
<xsl:for-each select="testcase[caseresult/@result=$FAIL]">
<xsl:call-template name="create-testcase-link">
<xsl:with-param name="testcase" select="."/>
</xsl:call-template>
</xsl:for-each>
<xsl:text> Errors: </xsl:text>
<xsl:for-each select="testcase[caseresult/@result=$ERRR]">
<xsl:call-template name="create-testcase-link">
<xsl:with-param name="testcase" select="."/>
</xsl:call-template>
</xsl:for-each>
<xsl:text> Ambiguous: </xsl:text>
<xsl:for-each select="testcase[caseresult/@result=$AMBG]">
<xsl:call-template name="create-testcase-link">
<xsl:with-param name="testcase" select="."/>
</xsl:call-template>
</xsl:for-each>
<xsl:text> Incomplete: </xsl:text>
<xsl:for-each select="testcase[caseresult/@result=$INCP]">
<xsl:call-template name="create-testcase-link">
<xsl:with-param name="testcase" select="."/>
</xsl:call-template>
</xsl:for-each>
</td>
</tr>
<tr>
<td>
<!-- Create a link to the hashtables for this file -->
<font size="-1">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="$hash-marker"/><xsl:value-of select="@filename"/></xsl:attribute>
<xsl:text>System.properties, etc. during the test</xsl:text>
</xsl:element>
</font>
</td>
</tr>
</table>
</xsl:template>
<!-- Output detail results from testcases, etc. -->
<xsl:template name="test-body">
<!-- Process all testcases and interim messages -->
<xsl:apply-templates select="*[not(name(.)='hashtable')]" />
</xsl:template>
<!-- Output any footer info, like environment hashes, etc. -->
<xsl:template name="test-footer">
<!-- @todo optimize so anchor only appears if there are hashtables -->
<br/>
<xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="$hash-marker"/><xsl:value-of select="@filename"/></xsl:attribute>
<xsl:text>System properties follow for: </xsl:text><xsl:value-of select="@filename"/>
</xsl:element>
<!-- Dump hashtables at the file level, which are system properties & etc. -->
<xsl:apply-templates select="hashtable"/>
</xsl:template>
<!-- 'Worker' template to convert loggingLevels -->
<!-- This is not terribly efficient, but it is prettier! -->
<xsl:template name="printLevel">
<xsl:param name="level"></xsl:param>
<xsl:choose>
<xsl:when test="$ERRORMSG=$level"><xsl:text>error</xsl:text></xsl:when>
<xsl:when test="$ERRORMSG=$level"><xsl:text>error</xsl:text></xsl:when>
<xsl:when test="$FAILSONLY=$level"><xsl:text>failmsg</xsl:text></xsl:when>
<xsl:when test="$WARNINGMSG=$level"><xsl:text>warning</xsl:text></xsl:when>
<xsl:when test="$STATUSMSG=$level"><xsl:text>status</xsl:text></xsl:when>
<xsl:when test="$INFOMSG=$level"><xsl:text>info</xsl:text></xsl:when>
<xsl:when test="$TRACEMSG=$level"><xsl:text>trace</xsl:text></xsl:when>
<xsl:otherwise><xsl:value-of select="$level"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ================================== -->
<!-- Element templates: output basic data for each of the common
test elements, like messages, checks, etc.
-->
<!-- Testfile is basically just a redirect to apply lower level templates -->
<xsl:template match="testcase">
<table frame="box" border="1" rules="groups"
cellspacing="2" cellpadding="2"
bgcolor="#FFFFEE">
<caption>
<b><xsl:text>Testcase # </xsl:text></b>
<!-- This creates the anchor as well as printing the @desc -->
<xsl:call-template name="create-testcase-anchor">
<xsl:with-param name="testcase" select="."/>
</xsl:call-template>
</caption>
<!-- establish row widths here -->
<tr>
<td width="20"></td>
<td></td>
</tr>
<!-- Normally, process all sub-elements using the table mode -->
<xsl:apply-templates mode="table"/>
<tr>
<td><br/><hr/></td>
<td><xsl:value-of select="caseresult/@result"/>:<xsl:text>Testcase #</xsl:text><xsl:value-of select="@desc"/></td>
</tr>
</table>
</xsl:template>
<!-- Handle checkresult statements: each test point's result -->
<xsl:template match="checkresult" mode="table">
<tr>
<td>
<xsl:call-template name="create-checkresult-anchor">
<xsl:with-param name="checkresult" select="."/>
</xsl:call-template>
</td>
<td>
<xsl:if test="@id">
<xsl:text>[</xsl:text><xsl:value-of select="@id"/><xsl:text>] </xsl:text>
</xsl:if>
<xsl:value-of select="@desc"/>
</td>
</tr>
</xsl:template>
<!-- Handle basic test messages: status, info, trace, etc. -->
<xsl:template match="message" mode="table">
<tr>
<td>
<xsl:call-template name="printLevel">
<xsl:with-param name="level" select="@level"/>
</xsl:call-template>
</td>
<td><xsl:value-of select="."/></td>
</tr>
</xsl:template>
<!-- Handle basic test messages when not in a testcase -->
<xsl:template match="message">
<p>
<xsl:call-template name="printLevel">
<xsl:with-param name="level" select="@level"/>
</xsl:call-template>
<xsl:text> : </xsl:text><xsl:value-of select="."/>
</p>
</xsl:template>
<!-- Handle arbitrary test messages: smaller font and preformatted -->
<xsl:template match="arbitrary" mode="table">
<tr>
<td>
<xsl:call-template name="printLevel">
<xsl:with-param name="level" select="@level"/>
</xsl:call-template>
</td>
<td><font size="-1"><pre><xsl:value-of select="."/></pre></font></td>
</tr>
</xsl:template>
<!-- Handle arbitrary test messages when not in a testcase -->
<xsl:template match="arbitrary">
<p>
<xsl:call-template name="printLevel">
<xsl:with-param name="level" select="@level"/>
</xsl:call-template>
<xsl:text> : </xsl:text>
<font size="-1"><pre><xsl:value-of select="."/></pre></font>
</p>
</xsl:template>
<!-- Handle fileCheck elements outputting info about files, etc.
Note that we copy the contents of the element, since some
tests might have element output here.
-->
<xsl:template match="fileCheck" mode="table">
<tr>
<td><font size="-1">fileCheck</font></td>
<td>
<xsl:text>Actual: </xsl:text>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@actual"/></xsl:attribute>
<xsl:value-of select="@actual"/>
</xsl:element><br/>
<xsl:text>Reference: </xsl:text>
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="@reference"/></xsl:attribute>
<xsl:value-of select="@reference"/>
</xsl:element><br/>
<br/>
<pre><font size="-1"><xsl:copy-of select="."/></font></pre>
</td>
</tr>
</xsl:template>
<!-- Handle perf info simplistically; print out all attrs as timing data -->
<xsl:template match="perf" mode="table">
<tr>
<td><font size="-1">perf</font></td>
<td>
<xsl:text>[</xsl:text><xsl:value-of select="@idref"/><xsl:text>]</xsl:text><br/>
<xsl:for-each select="attribute::*">
<xsl:choose>
<!-- Skip unneeded attrs -->
<xsl:when test="'level' = name()"/>
<xsl:when test="'testlet' = name()"/>
<xsl:when test="'idref' = name()"/>
<xsl:when test="'actual' = name()"/>
<xsl:when test="'reference' = name()"/>
<!-- Output any other perf-related attrs, whatever they are -->
<xsl:otherwise>
<xsl:value-of select="name()"/><xsl:text> = </xsl:text><xsl:value-of select="."/><br/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</td>
</tr>
</xsl:template>
<!-- Handle basic hashtables and items within them -->
<xsl:template match="hashtable">
<table border="1" width="80%" cellspacing="1" cellpadding="2">
<caption><xsl:value-of select="@desc"/></caption>
<xsl:apply-templates select="hashitem"/>
</table>
</xsl:template>
<xsl:template match="hashitem">
<tr>
<td><xsl:value-of select="@key"/></td>
<td>
<!-- Integrate with S4JLoadUtil: create links to loaded schemas -->
<xsl:choose>
<xsl:when test="@key='current-file'">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
<xsl:value-of select="."/>
</xsl:element>
</xsl:when>
<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:template>
<!-- Handle basic hashtables and items when in a table, which is a bit tricky -->
<xsl:template match="hashtable" mode="table">
<tr>
<td><xsl:text>hash</xsl:text></td>
<td>
<table border="1" width="80%" cellspacing="1" cellpadding="2">
<caption><xsl:value-of select="@desc"/></caption>
<xsl:apply-templates select="hashitem"/><!-- note no mode needed -->
</table>
</td>
</tr>
</xsl:template>
<!-- Worker template to make testcase links: @desc is in anchor -->
<xsl:template name="create-testcase-link">
<xsl:param name="testcase"></xsl:param>
<font size="-1">
<xsl:element name="a">
<xsl:attribute name="href"><xsl:value-of select="$testcase-marker"/><xsl:value-of select="translate($testcase/@desc,'\ ','-')"/></xsl:attribute>
<xsl:text>Testcase#</xsl:text><xsl:value-of select="substring-before($testcase/@desc,' ')"/>
</xsl:element>
<xsl:text>, </xsl:text>
</font>
</xsl:template>
<!-- Worker template to make testcase anchors: @desc is in anchor -->
<xsl:template name="create-testcase-anchor">
<xsl:param name="testcase"></xsl:param>
<xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="$testcase-marker"/><xsl:value-of select="translate($testcase/@desc,'\ ','-')"/></xsl:attribute>
<xsl:value-of select="@desc"/>
</xsl:element>
</xsl:template>
<!-- Worker template to make checkresult anchors: @result is in anchor -->
<xsl:template name="create-checkresult-anchor">
<xsl:param name="checkresult"></xsl:param>
<xsl:element name="a">
<xsl:attribute name="name"><xsl:value-of select="$checkresult-marker"/><xsl:value-of select="translate($checkresult/@desc,'\ ','-')"/></xsl:attribute>
<xsl:value-of select="@result"/>
</xsl:element>
</xsl:template>
<!-- Override default text node processing, so statistics and other misc text is skipped -->
<xsl:template match="text()"/>
<xsl:template match="text()" mode="table"/>
</xsl:stylesheet>