diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 23:40:36 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 23:40:36 -0800 |
commit | 8f08bb9a9d61f512be6a4d0ff8e96263b8672e24 (patch) | |
tree | 313627b2203c27e9d6c43bcccf19c512246f12ef | |
parent | 86621c853b050ed08ed7edc9156b3a774867974c (diff) |
stash - import more crap from summary-flexbox
-rwxr-xr-x | programs/report.py | 89 |
1 files changed, 87 insertions, 2 deletions
diff --git a/programs/report.py b/programs/report.py index 2b80dc6..7ded68a 100755 --- a/programs/report.py +++ b/programs/report.py @@ -30,6 +30,88 @@ import sys from framework.database import ResultDatabase + +############################################################################# +##### Helper functions +############################################################################# + +filename_char_re = re.compile(r'[^a-zA-Z_]+') +def escape(s): + return filename_char_re.sub('', s.replace('/', '__')) + +############################################################################# +##### Summary page generation +############################################################################# + +class StackEntry: + def __init__(self, num_runs, group_name): + self.name = group_name + #self.results = [PassVector(0,0,0,0,0,0,0) for i in range(num_runs)] + self.name_html = '' + self.column_html = ['' for i in range(num_runs)] + +def buildTable(run_names, results): + # If the test list is empty, just return now. + if not results: + return ('', ['']) + + num_runs = len(run_names) + + last_group = '' + stack = [] + + def openGroup(name): + stack.append(StackEntry(num_runs, name)) + + def closeGroup(): + group = stack.pop() + + stack[-1].name_html += ''.join(['<div class="group"><div class="head">', group.name, '</div><div class="groupbody">', group.name_html, '</div></div>']) + + for i in range(num_runs): + stack[-1].results[i].add(group.results[i]) + stack[-1].column_html[i] += ''.join(['<div class="group">', buildGroupResultHeader(group.results[i]), group.column_html[i], '</div>']) + + openGroup('fake') + openGroup('All') + + for full_test in results.keys(): + group, test = path.split(full_test) # or full_test.rpartition('/') + + if group != last_group: + # We're in a different group now. Close the old ones + # and open the new ones. + for x in path.relpath(group, last_group).split('/'): + if x == '..': + closeGroup() + else: + openGroup(x) + + last_group = group + + # Add the current test + stack[-1].name_html += '<div>' + test + '</div>\n'; + for i in range(num_runs): + passv, html = testResult(summary, summary.testruns[i], full_test, summary.results[full_test][i]) + stack[-1].results[i].add(passv) + stack[-1].column_html[i] += html + + # Close any remaining groups + while len(stack) > 1: + closeGroup() + + assert(len(stack) == 1) + + return (stack[0].name_html, stack[0].column_html) + +def writeSummaryHtml(): + names, columns = buildTable(...) + + #def makeColumn(name, contents): + #return ''.join(['<div class="resultColumn"><div class="title"><b>%s</b><br/>(<a href="%s/index.html">info</a>)</div>' % (name, escape(name)), contents, '</div>']) + + #column_html = ''.join([makeColumn(name, contents) for name, contents in zip(run_names, columns)]) + ############################################################################# ##### Main program ############################################################################# @@ -52,12 +134,15 @@ def main(argv, config): if not path.exists(reportDir): os.makedirs(reportDir) - results = db.getResults(list(args.runs)) + run_names = list(args.runs) + results = db.getResults(run_names) + + # XXX: write detail pages print(results) #os.link(path.join(templateDir, 'index.css'), #path.join(reportDir, 'index.css')) - #writeSummaryHtml(summary, summaryDir, 'all') + writeSummaryHtml() if __name__ == "__main__": |