3 import posixpath # this must be posixpath, since we want /'s not \'s
6 from framework import grouptools, status
8 def group_changes(test, current):
9 group = grouptools.groupname(test)
10 common = grouptools.commonprefix((current, group))
12 common = grouptools.split(common)
13 open = grouptools.split(group)[len(common):]
14 close = grouptools.split(current)[len(common):]
18 def group_result(result, group):
19 """Get the worst status in a group."""
20 if group not in result.totals:
23 return max([status.status_lookup(s) for s, v in
24 result.totals[group].items() if v > 0])
26 def group_fraction(result, group):
27 """Get the fraction value for a group."""
28 if group not in result.totals:
33 for k, v in result.totals[group].items():
35 s = status.status_lookup(k)
36 num += s.fraction[0] * v
37 den += s.fraction[1] * v
39 return '{}/{}'.format(num, den)
42 def escape_filename(key):
43 """Avoid reserved characters in filenames."""
44 return re.sub(r'[<>:"|?*#]', '_', key)
47 def escape_pathname(key):
48 """ Remove / and \\ from names """
49 return re.sub(r'[/\\]', '_', key)
52 def normalize_href(href):
53 """Force backward slashes in URLs."""
54 return href.replace('\\', '/')
60 <meta charset="UTF-8">
61 <title>Result summary</title>
62 <link rel="stylesheet" href="index.css">
65 <h1>Result summary</h1>
66 <p>Currently showing: ${page}</p>
71 <a href="index.html">all</a>
77 | <a href="${i}.html">${i}</a>
87 ## Create an additional column for each summary
88 % for _ in range(len(results.results)):
94 % for res in results.results:
95 <th class="head"><b>${res.name}</b><br>\
96 (<a href="${normalize_href(os.path.join(escape_pathname(res.name), 'index.html'))}">info</a>)</th>
100 <td class="head"><b>all</b></td>
101 % for res in results.results:
102 <td class="${group_result(res, 'root')}">
103 <b>${group_fraction(res, 'root')}</b>
111 % for test in sorted(getattr(results.names, page if page == 'all' else 'all_' + page)):
113 open, close = group_changes(test, group)
114 depth -= len(close) # lower the indent for the groups we're not using
116 # remove the groups we're not using from current
117 group = grouptools.split(group)[:-len(close)]
119 group = grouptools.join(*group)
126 <% group = grouptools.join(group, elem) %>
127 ## Add the left most column, the name of the group
129 <div class="head" style="margin-left: ${depth * 1.75}em">
133 ## add each group's totals
134 % for res in results.results:
135 <td class="${group_result(res, group)}">
136 <b>${group_fraction(res, group)}</b>
145 <div class="group" style="margin-left: ${depth * 1.75}em">
146 ${grouptools.testname(test) | h}
149 % for res in results.results:
151 # Get the raw result, if it's none check to see if it's a subtest, if that's still None
152 # then declare it not run
153 # This very intentionally uses posix path, we're generating urls, and while
154 # some windows based browsers support \\ as a url separator, *nix systems do not,
155 # which would make a result generated on windows non-portable
156 raw = res.tests.get(test)
159 href = normalize_href(posixpath.join(escape_pathname(res.name),
160 escape_filename(test)))
162 raw = res.tests.get(grouptools.groupname(test))
163 name = grouptools.testname(test)
164 if raw is not None and name in raw.subtests:
165 result = raw.subtests[name]
166 href = normalize_href(posixpath.join(escape_pathname(res.name),
167 escape_filename(grouptools.groupname(test))))
169 result = status.NOTRUN
170 del raw # we don't need this, so don't let it leak
172 <td class="${str(result)}">
173 % if str(result) not in exclude and result is not status.NOTRUN:
174 <a href="${href}.html">