3 import posixpath # this must be posixpath, since we want /'s not \'s
5 from framework import grouptools, status
7 def group_changes(test, current):
8 group = grouptools.groupname(test)
9 common = grouptools.commonprefix((current, group))
11 common = grouptools.split(common)
12 open = grouptools.split(group)[len(common):]
13 close = grouptools.split(current)[len(common):]
17 def group_result(result, group):
18 """Get the worst status in a group."""
19 if group not in result.totals:
22 return max([status.status_lookup(s) for s, v in
23 result.totals[group].iteritems() if v > 0])
25 def group_fraction(result, group):
26 """Get the fraction value for a group."""
27 if group not in result.totals:
32 for k, v in result.totals[group].iteritems():
34 s = status.status_lookup(k)
35 num += s.fraction[0] * v
36 den += s.fraction[1] * v
38 return '{}/{}'.format(num, den)
41 def escape_filename(key):
42 """Avoid reserved characters in filenames."""
43 return re.sub(r'[<>:"|?*#]', '_', key)
46 def escape_pathname(key):
47 """ Remove / and \\ from names """
48 return re.sub(r'[/\\]', '_', key)
51 def normalize_href(href):
52 """Force backward slashes in URLs."""
53 return href.replace('\\', '/')
56 <?xml version="1.0" encoding="UTF-8"?>
57 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
58 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
59 <html xmlns="http://www.w3.org/1999/xhtml">
61 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
62 <title>Result summary</title>
63 <link rel="stylesheet" href="index.css" type="text/css" />
66 <h1>Result summary</h1>
67 <p>Currently showing: ${page}</p>
72 <a href="index.html">all</a>
78 | <a href="${i}.html">${i}</a>
88 ## Create an additional column for each summary
89 % for _ in xrange(len(results.results)):
95 % for res in results.results:
96 <th class="head"><b>${res.name}</b><br />\
97 (<a href="${normalize_href(os.path.join(escape_pathname(res.name), 'index.html'))}">info</a>)</th>
101 <td class="head"><b>all</b></td>
102 % for res in results.results:
103 <td class="${group_result(res, 'root')}">
104 <b>${group_fraction(res, 'root')}</b>
112 % for test in sorted(getattr(results.names, page if page == 'all' else 'all_' + page)):
114 open, close = group_changes(test, group)
115 depth -= len(close) # lower the indent for the groups we're not using
117 # remove the groups we're not using from current
118 group = grouptools.split(group)[:-len(close)]
120 group = grouptools.join(*group)
127 <% group = grouptools.join(group, elem) %>
128 ## Add the left most column, the name of the group
130 <div class="head" style="margin-left: ${depth * 1.75}em">
134 ## add each group's totals
135 % for res in results.results:
136 <td class="${group_result(res, group)}">
137 <b>${group_fraction(res, group)}</b>
146 <div class="group" style="margin-left: ${depth * 1.75}em">
147 ${grouptools.testname(test)}
150 % for res in results.results:
152 # Get the raw result, if it's none check to see if it's a subtest, if that's still None
153 # then declare it not run
154 # This very intentionally uses posix path, we're generating urls, and while
155 # some windows based browsers support \\ as a url separator, *nix systems do not,
156 # which would make a result generated on windows non-portable
157 raw = res.tests.get(test)
160 href = normalize_href(posixpath.join(escape_pathname(res.name),
161 escape_filename(test)))
163 raw = res.tests.get(grouptools.groupname(test))
164 name = grouptools.testname(test)
165 if raw is not None and name in raw.subtests:
166 result = raw.subtests[name]
167 href = normalize_href(posixpath.join(escape_pathname(res.name),
168 escape_filename(grouptools.groupname(test))))
170 result = status.NOTRUN
171 del raw # we dont need this, so don't let it leak
173 <td class="${str(result)}">
174 % if str(result) not in exclude and result is not status.NOTRUN:
175 <a href="${href}.html">