3 import posixpath # this must be posixpath, since we want /'s not \'s
7 from six.moves import range
9 from framework import grouptools, status
11 def group_changes(test, current):
12 group = grouptools.groupname(test)
13 common = grouptools.commonprefix((current, group))
15 common = grouptools.split(common)
16 open = grouptools.split(group)[len(common):]
17 close = grouptools.split(current)[len(common):]
21 def group_result(result, group):
22 """Get the worst status in a group."""
23 if group not in result.totals:
26 return max([status.status_lookup(s) for s, v in
27 six.iteritems(result.totals[group]) if v > 0])
29 def group_fraction(result, group):
30 """Get the fraction value for a group."""
31 if group not in result.totals:
36 for k, v in six.iteritems(result.totals[group]):
38 s = status.status_lookup(k)
39 num += s.fraction[0] * v
40 den += s.fraction[1] * v
42 return '{}/{}'.format(num, den)
45 def escape_filename(key):
46 """Avoid reserved characters in filenames."""
47 return re.sub(r'[<>:"|?*#]', '_', key)
50 def escape_pathname(key):
51 """ Remove / and \\ from names """
52 return re.sub(r'[/\\]', '_', key)
55 def normalize_href(href):
56 """Force backward slashes in URLs."""
57 return href.replace('\\', '/')
63 <meta charset="UTF-8">
64 <title>Result summary</title>
65 <link rel="stylesheet" href="index.css">
68 <h1>Result summary</h1>
69 <p>Currently showing: ${page}</p>
74 <a href="index.html">all</a>
80 | <a href="${i}.html">${i}</a>
90 ## Create an additional column for each summary
91 % for _ in range(len(results.results)):
97 % for res in results.results:
98 <th class="head"><b>${res.name}</b><br>\
99 (<a href="${normalize_href(os.path.join(escape_pathname(res.name), 'index.html'))}">info</a>)</th>
103 <td class="head"><b>all</b></td>
104 % for res in results.results:
105 <td class="${group_result(res, 'root')}">
106 <b>${group_fraction(res, 'root')}</b>
114 % for test in sorted(getattr(results.names, page if page == 'all' else 'all_' + page)):
116 open, close = group_changes(test, group)
117 depth -= len(close) # lower the indent for the groups we're not using
119 # remove the groups we're not using from current
120 group = grouptools.split(group)[:-len(close)]
122 group = grouptools.join(*group)
129 <% group = grouptools.join(group, elem) %>
130 ## Add the left most column, the name of the group
132 <div class="head" style="margin-left: ${depth * 1.75}em">
136 ## add each group's totals
137 % for res in results.results:
138 <td class="${group_result(res, group)}">
139 <b>${group_fraction(res, group)}</b>
148 <div class="group" style="margin-left: ${depth * 1.75}em">
149 ${grouptools.testname(test) | h}
152 % for res in results.results:
154 # Get the raw result, if it's none check to see if it's a subtest, if that's still None
155 # then declare it not run
156 # This very intentionally uses posix path, we're generating urls, and while
157 # some windows based browsers support \\ as a url separator, *nix systems do not,
158 # which would make a result generated on windows non-portable
159 raw = res.tests.get(test)
162 href = normalize_href(posixpath.join(escape_pathname(res.name),
163 escape_filename(test)))
165 raw = res.tests.get(grouptools.groupname(test))
166 name = grouptools.testname(test)
167 if raw is not None and name in raw.subtests:
168 result = raw.subtests[name]
169 href = normalize_href(posixpath.join(escape_pathname(res.name),
170 escape_filename(grouptools.groupname(test))))
172 result = status.NOTRUN
173 del raw # we don't need this, so don't let it leak
175 <td class="${str(result)}">
176 % if str(result) not in exclude and result is not status.NOTRUN:
177 <a href="${href}.html">