sso: test program pipeline with atomic counters
[piglit.git] / templates / index.mako
blobd2b84b5c0a8a1ae606bc749deb05834a4920723b
1 <%!
2   import os
3   import posixpath  # this must be posixpath, since we want /'s not \'s
4   import re
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):]
15       return open, close
17   def group_result(result, group):
18       """Get the worst status in a group."""
19       if group not in result.totals:
20           return status.NOTRUN
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:
28           return '0/0'
30       num = 0
31       den = 0
32       for k, v in result.totals[group].iteritems():
33           if v > 0:
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">
60   <head>
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" />
64   </head>
65   <body>
66     <h1>Result summary</h1>
67     <p>Currently showing: ${page}</p>
68     <p>Show:
69       % if page == 'all':
70         all
71       % else:
72         <a href="index.html">all</a>
73       % endif
74       % for i in pages:
75         % if i == page:
76           | ${i}
77         % else:
78           | <a href="${i}.html">${i}</a>
79         % endif
80       % endfor
81     </p>
82     <table>
83       <colgroup>
84         ## Name Column
85         <col />
87         ## Status columns
88         ## Create an additional column for each summary
89         % for _ in xrange(len(results.results)):
90         <col />
91         % endfor
92       </colgroup>
93       <tr>
94         <th/>
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>
98         % endfor
99       </tr>
100       <tr>
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>
105           </td>
106         % endfor
107       </tr>
108       <%
109         depth = 1
110         group = ''
111       %>
112       % for test in sorted(getattr(results.names, page if page == 'all' else 'all_' + page)):
113         <%
114           open, close = group_changes(test, group)
115           depth -= len(close)  # lower the indent for the groups we're not using
116           if close:
117             # remove the groups we're not using from current
118             group = grouptools.split(group)[:-len(close)]
119             if group:
120               group = grouptools.join(*group)
121             else:
122               group = ''
123         %>
124         <tr>
125         % if open:
126           % for elem in open:
127             <% group = grouptools.join(group, elem) %>
128             ## Add the left most column, the name of the group
129             <td>
130               <div class="head" style="margin-left: ${depth * 1.75}em">
131                 <b>${elem}</b>
132               </div>
133             </td>
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>
138               </td>
139             % endfor
140             <% depth += 1 %>
141             </tr><tr>
142           % endfor
143         % endif
144         
145         <td>
146           <div class="group" style="margin-left: ${depth * 1.75}em">
147             ${grouptools.testname(test)}
148           </div>
149         </td>
150         % for res in results.results:
151           <%
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)
158             if raw is not None:
159               result = raw.result
160               href = normalize_href(posixpath.join(escape_pathname(res.name),
161                                                    escape_filename(test)))
162             else:
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))))
169               else:
170                 result = status.NOTRUN
171             del raw  # we dont need this, so don't let it leak
172           %>
173           <td class="${str(result)}">
174           % if str(result) not in exclude and result is not status.NOTRUN:
175             <a href="${href}.html">
176               ${str(result)}
177             </a>
178           % else:
179             ${str(result)}
180           % endif
181           </td>
182         % endfor
183         </tr>
184       % endfor
185     </table>
186   </body>
187 </html>