/
results.xsl
300 lines (282 loc) · 18.6 KB
/
results.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
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="stylesheet">
<xsl:output method="xml" doctype-system="about:legacy-compat" indent="yes" encoding="UTF-8"/>
<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Results | Steward</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5/dist/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1/font/bootstrap-icons.min.css" rel="stylesheet"/>
</head>
<body>
<xsl:variable name="in-progress" select="count(//testcase) > count(//testcase[@status='done'])" />
<div class="container">
<div class="pb-0 mt-4 mb-4 border-bottom d-flex align-items-center">
<h1>Steward results</h1>
<xsl:if test="$in-progress">
<div class="spinner-border ms-auto" role="status" aria-hidden="true" title="Test are still in progress"></div>
</xsl:if>
</div>
<div class="row mb-4">
<div class="col-6">
<div class="card">
<div class="card-header">
<h1>
<xsl:value-of select="count(//testcase)"/>
<xsl:choose>
<xsl:when test="count(//testcase) = 1">
testcase
</xsl:when>
<xsl:otherwise>
testcases
</xsl:otherwise>
</xsl:choose>
</h1>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">prepared: <xsl:value-of select="count(//testcase[@status='prepared'])"/></li>
<li class="list-group-item">queued: <xsl:value-of select="count(//testcase[@status='queued'])"/></li>
<li class="list-group-item">
done: <xsl:value-of select="count(//testcase[@status='done'])"/>
<ul style="list-style-type: none; padding-left: 20px;">
<li>
<i class="bi bi-check-lg"></i>
passed: <xsl:value-of select="count(//testcase[@status='done' and @result='passed'])"/>
</li>
<li>
<i class="bi bi-x-circle-fill"></i>
failed: <xsl:value-of select="count(//testcase[@status='done' and @result='failed'])"/>
</li>
<li>
<i class="bi bi-exclamation-triangle"></i>
fatal: <xsl:value-of select="count(//testcase[@status='done' and @result='fatal'])"/>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="col-6">
<div class="card">
<div class="card-header">
<h1>
<xsl:value-of select="count(//test)"/>
<xsl:choose>
<xsl:when test="count(//test) = 1">
test
</xsl:when>
<xsl:otherwise>
tests
</xsl:otherwise>
</xsl:choose>
<xsl:if test="$in-progress">
<small class="text-body-secondary" style="font-size: 0.5em">(initialized so far)</small>
</xsl:if>
</h1>
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item">started: <xsl:value-of select="count(//test[@status='started'])"/></li>
<li class="list-group-item">
done: <xsl:value-of select="count(//test[@status='done'])"/>
<ul style="list-style-type: none; padding-left: 20px;">
<li>
<i class="bi bi-check-lg"></i>
passed: <xsl:value-of select="count(//test[@status='done' and @result='passed'])"/>
</li>
<li>
<i class="bi bi-x-circle-fill"></i>
failed or broken: <xsl:value-of select="count(//test[@status='done' and (@result='failed' or @result='broken')])"/>
</li>
<li>
<i class="bi bi-question-circle"></i>
skipped or incomplete: <xsl:value-of select="count(//test[@status='done' and (@result='skipped' or @result='incomplete')])"/>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<xsl:variable name="testcase-progress-passed" select="round(100 div count(//testcase) * count(//testcase[@status='done' and @result='passed']))" />
<xsl:variable name="testcase-progress-failed-and-fatal" select="round(100 div count(//testcase) * count(//testcase[@status='done' and (@result='failed' or @result='fatal')]))" />
<div class="progress mb-4" style="height: 2em">
<div style="width: {$testcase-progress-failed-and-fatal}%">
<xsl:attribute name="class">
<xsl:text>progress-bar bg-danger</xsl:text>
<xsl:if test="$in-progress"> progress-bar-striped progress-bar-animated</xsl:if>
</xsl:attribute><xsl:value-of select="$testcase-progress-failed-and-fatal"/> %
</div>
<div style="width: {$testcase-progress-passed}%">
<xsl:attribute name="class">
<xsl:text>progress-bar bg-success</xsl:text>
<xsl:if test="$in-progress"> progress-bar-striped progress-bar-animated</xsl:if>
</xsl:attribute>
<xsl:if test="count(//testcase[@status='done']) < 1">
<xsl:attribute name="aria-valuenow">0</xsl:attribute>
</xsl:if>
<xsl:value-of select="$testcase-progress-passed"/> %
</div>
</div>
<table class="table table-sm table-hover results-table">
<thead>
<tr>
<th colspan="2">Testcase / tests</th>
<th>Status</th>
<th>Result</th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
</tr>
</thead>
<tbody class="table-group-divider">
<xsl:for-each select="//testcases/testcase">
<tr class="testcase-row table-active">
<td colspan="2" style="word-break: break-all;" class="w-50">
<xsl:value-of select="@name"/>
</td>
<td>
<xsl:value-of select="@status"/>
</td>
<td>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@result = 'passed'">bg-success-subtle</xsl:when>
<xsl:when test="@result = 'failed'">bg-danger-subtle</xsl:when>
<xsl:when test="@result = 'fatal'">bg-warning-subtle</xsl:when>
</xsl:choose>
</xsl:attribute>
<!-- if the status is queued (this result is not yet know) only add time icon -->
<xsl:if test="@status = 'queued'">
<i class="bi bi-clock"></i>
</xsl:if>
<i>
<xsl:attribute name="class">
bi
<xsl:choose>
<xsl:when test="@result = 'passed'">bi-check-lg</xsl:when>
<xsl:when test="@result = 'failed'">bi-x-circle-fill</xsl:when>
<xsl:when test="@result = 'fatal'">bi-exclamation-triangle</xsl:when>
</xsl:choose>
</xsl:attribute>
</i>
<xsl:text>  </xsl:text>
<xsl:value-of select="@result"/>
</td>
<td class="date date-start">
<xsl:value-of select="@start"/>
</td>
<td class="date date-end">
<xsl:value-of select="@end"/>
</td>
<td class="duration">
</td>
</tr>
<xsl:if test="test">
<xsl:for-each select="test">
<tr class="test-row">
<td></td>
<td style="word-break: break-all;">
<xsl:attribute name="title">
<xsl:value-of select="../@name"/>::<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:value-of select="@name"/>
</td>
<td>
<!-- If the parent testcase ended with "fatal" and this one is still in "started" status, that
this must be the one that "fatal"-ed, so we won't print its confusing "started" status -->
<xsl:if test="not(@status = 'started' and ../@result = 'fatal')">
<xsl:value-of select="@status"/>
</xsl:if>
</td>
<td>
<xsl:choose>
<xsl:when test="@status = 'started' and ../@result = 'fatal'">
<xsl:attribute name="class">warning</xsl:attribute>
<i class="bi bi-exclamation-triangle"></i>  fatal
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="class">
<xsl:choose>
<xsl:when test="@result = 'passed'">bg-success-subtle</xsl:when>
<xsl:when test="@result = 'failed' or @result = 'broken'">bg-danger-subtle</xsl:when>
<xsl:when test="@result = 'skipped' or @result = 'incomplete'">bg-info-subtle</xsl:when>
</xsl:choose>
</xsl:attribute>
<i>
<xsl:attribute name="class">
bi
<xsl:choose>
<xsl:when test="@result = 'passed'">bi-check-lg</xsl:when>
<xsl:when test="@result = 'failed' or @result = 'broken'">bi-x-circle-fill</xsl:when>
<xsl:when test="@result = 'skipped' or @result = 'incomplete'">bi-question-circle</xsl:when>
</xsl:choose>
</xsl:attribute>
</i>
<xsl:text>  </xsl:text>
<xsl:value-of select="@result"/>
</xsl:otherwise>
</xsl:choose>
</td>
<td class="date date-start">
<xsl:value-of select="@start"/>
</td>
<td class="date date-end">
<xsl:choose>
<xsl:when test="@status = 'started' and ../@result = 'fatal'">-</xsl:when>
<xsl:otherwise><xsl:value-of select="@end"/></xsl:otherwise>
</xsl:choose>
</td>
<td class="duration">
</td>
</tr>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment@2/moment.min.js"></script>
<script>
<![CDATA[
$(function () {
// Ensure the script was not yet initialized (see Firefox bug #380828)
if (typeof window.wasInitialized != 'undefined') {
return;
}
window.wasInitialized = true;
// calculate and print test duration
$('table tr.test-row, table tr.testcase-row').each(function() {
var startDate = moment($('td.date-start', this).text());
var endValue = $('td.date-end', this).text();
var endDate = moment(endValue);
var isPending = false;
if (startDate.isValid() && endValue != '-') { // do not calculate when test fatal-ed
if (!endDate.isValid()) { // still running, add current time
isPending = true;
endDate = moment();
}
$('td.duration', this).html(
(isPending ? '<i>' : '') +
endDate.diff(startDate, 'seconds') + ' sec' +
(isPending ? '</i>' : '')
);
}
});
// convert ISO-8601 dates to more readable ones
$("td.date").each(function () {
if ($(this).text().length && $(this).text() != '-') {
$(this).text(moment($(this).text()).format('YYYY-MM-DD H:mm:ss'));
}
});
});
]]>
</script>
</body>
</html>
</xsl:template>
<xsl:template match="xsl:stylesheet">
<!-- ignore the stylesheet from being processed -->
</xsl:template>
</xsl:stylesheet>