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
|
<%!
import os
import posixpath # this must be posixpath, since we want /'s not \'s
import re
from framework import grouptools, status
def group_changes(test, current):
group = grouptools.groupname(test)
common = grouptools.commonprefix((current, group))
common = grouptools.split(common)
open = grouptools.split(group)[len(common):]
close = grouptools.split(current)[len(common):]
return open, close
def group_result(result, group):
"""Get the worst status in a group."""
if group not in result.totals:
return status.NOTRUN
return max([status.status_lookup(s) for s, v in
result.totals[group].iteritems() if v > 0])
def group_fraction(result, group):
"""Get the fraction value for a group."""
if group not in result.totals:
return '0/0'
num = 0
den = 0
for k, v in result.totals[group].iteritems():
if v > 0:
s = status.status_lookup(k)
num += s.fraction[0] * v
den += s.fraction[1] * v
return '{}/{}'.format(num, den)
def escape_filename(key):
"""Avoid reserved characters in filenames."""
return re.sub(r'[<>:"|?*#]', '_', key)
def escape_pathname(key):
""" Remove / and \\ from names """
return re.sub(r'[/\\]', '_', key)
def normalize_href(href):
"""Force backward slashes in URLs."""
return href.replace('\\', '/')
%>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Result summary</title>
<link rel="stylesheet" href="index.css" type="text/css" />
</head>
<body>
<h1>Result summary</h1>
<p>Currently showing: ${page}</p>
<p>Show:
% if page == 'all':
all
% else:
<a href="index.html">all</a>
% endif
% for i in pages:
% if i == page:
| ${i}
% else:
| <a href="${i}.html">${i}</a>
% endif
% endfor
</p>
<table>
<colgroup>
## Name Column
<col />
## Status columns
## Create an additional column for each summary
% for _ in xrange(len(results.results)):
<col />
% endfor
</colgroup>
<tr>
<th/>
% for res in results.results:
<th class="head"><b>${res.name}</b><br />\
(<a href="${normalize_href(os.path.join(escape_pathname(res.name), 'index.html'))}">info</a>)</th>
% endfor
</tr>
<tr>
<td class="head"><b>all</b></td>
% for res in results.results:
<td class="${group_result(res, 'root')}">
<b>${group_fraction(res, 'root')}</b>
</td>
% endfor
</tr>
<%
depth = 1
group = ''
%>
% for test in sorted(getattr(results.names, page if page == 'all' else 'all_' + page)):
<%
open, close = group_changes(test, group)
depth -= len(close) # lower the indent for the groups we're not using
if close:
# remove the groups we're not using from current
group = grouptools.split(group)[:-len(close)]
if group:
group = grouptools.join(*group)
else:
group = ''
%>
<tr>
% if open:
% for elem in open:
<% group = grouptools.join(group, elem) %>
## Add the left most column, the name of the group
<td>
<div class="head" style="margin-left: ${depth * 1.75}em">
<b>${elem}</b>
</div>
</td>
## add each group's totals
% for res in results.results:
<td class="${group_result(res, group)}">
<b>${group_fraction(res, group)}</b>
</td>
% endfor
<% depth += 1 %>
</tr><tr>
% endfor
% endif
<td>
<div class="group" style="margin-left: ${depth * 1.75}em">
${grouptools.testname(test)}
</div>
</td>
% for res in results.results:
<%
# Get the raw result, if it's none check to see if it's a subtest, if that's still None
# then declare it not run
# This very intentionally uses posix path, we're generating urls, and while
# some windows based browsers support \\ as a url separator, *nix systems do not,
# which would make a result generated on windows non-portable
raw = res.tests.get(test)
if raw is not None:
result = raw.result
href = normalize_href(posixpath.join(escape_pathname(res.name),
escape_filename(test)))
else:
raw = res.tests.get(grouptools.groupname(test))
if raw is not None:
result = raw.subtests[grouptools.testname(test)]
href = normalize_href(posixpath.join(escape_pathname(res.name),
escape_filename(grouptools.groupname(test))))
else:
result = status.NOTRUN
del raw # we dont need this, so don't let it leak
%>
<td class="${str(result)}">
% if str(result) not in exclude and result is not status.NOTRUN:
<a href="${href}.html">
${str(result)}
</a>
% else:
${str(result)}
% endif
</td>
% endfor
</tr>
% endfor
</table>
</body>
</html>
|