[Piglit] [PATCH 11/12] HTML Summary: Don't generate empty pages
Dylan Baker
baker.dylan.c at gmail.com
Thu May 9 23:09:25 PDT 2013
Previously every page (fixes, regressions, etc) was generated regardless
of whether there was anything on that page. That is simply silly, this
patch does a quick check and only generates pages that actually have
content, and add those pages to the link bar at the top of the page.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
framework/summary.py | 92 ++++++++++++++++++++++++++++++++++------------------
templates/index.mako | 4 +--
2 files changed, 63 insertions(+), 33 deletions(-)
diff --git a/framework/summary.py b/framework/summary.py
index 5288543..ecaa804 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -667,54 +667,84 @@ class NewSummary:
output_encoding = "utf-8",
module_directory = ".makotmp")
+ # Figure out which pages need to be built, then only build those pages
+ # and only add those pages to the link bar at the top
+ links = ['index', 'changes', 'problems', 'skipped', 'fixes',
+ 'regressions']
+
+ if not self.changes:
+ links.remove('changes')
+ if not self.problems:
+ links.remove('problems')
+ if not self.skipped:
+ links.remove('skipped')
+ if not self.fixes:
+ links.remove('fixes')
+ if not self.regressions:
+ links.remove('regressions')
+
# Index.html
file = open(path.join(destination, "index.html"), 'w')
file.write(index.render(results = BuildHTMLIndex(self, self.alltests),
page = 'all',
colnum = len(self.results),
+ links = links,
exclude = exclude))
file.close()
# changes.html
- file = open(path.join(destination, "changes.html"), 'w')
- file.write(index.render(results = BuildHTMLIndex(self, self.changes),
- page = 'changes',
- colnum = len(self.results),
- exclude = exclude))
- file.close()
+ if self.changes:
+ file = open(path.join(destination, "changes.html"), 'w')
+ file.write(index.render(results = BuildHTMLIndex(self,
+ self.changes),
+ page = 'changes',
+ colnum = len(self.results),
+ links = links,
+ exclude = exclude))
+ file.close()
# problems.html
- file = open(path.join(destination, "problems.html"), 'w')
- file.write(index.render(results = BuildHTMLIndex(self, self.problems),
- page = 'problems',
- colnum = len(self.results),
- exclude = exclude))
- file.close()
+ if self.problems:
+ file = open(path.join(destination, "problems.html"), 'w')
+ file.write(index.render(results = BuildHTMLIndex(self,
+ self.problems),
+ page = 'problems',
+ colnum = len(self.results),
+ links = links,
+ exclude = exclude))
+ file.close()
# skipped.html
- file = open(path.join(destination, "skipped.html"), 'w')
- file.write(index.render(results = BuildHTMLIndex(self, self.skipped),
- page = 'skipped',
- colnum = len(self.results),
- exclude = exclude))
- file.close()
+ if self.skipped:
+ file = open(path.join(destination, "skipped.html"), 'w')
+ file.write(index.render(results = BuildHTMLIndex(self,
+ self.skipped),
+ page = 'skipped',
+ colnum = len(self.results),
+ links = links,
+ exclude = exclude))
+ file.close()
# fixes.html
- file = open(path.join(destination, "fixes.html"), 'w')
- file.write(index.render(results = BuildHTMLIndex(self, self.fixes),
- page = 'fixes',
- colnum = len(self.results),
- exclude = exclude))
- file.close()
+ if self.fixes:
+ file = open(path.join(destination, "fixes.html"), 'w')
+ file.write(index.render(results = BuildHTMLIndex(self, self.fixes),
+ page = 'fixes',
+ colnum = len(self.results),
+ links = links,
+ exclude = exclude))
+ file.close()
# regressions.html
- file = open(path.join(destination, "regressions.html"), 'w')
- file.write(index.render(results = BuildHTMLIndex(self,
- self.regressions),
- page = 'regressions',
- colnum = len(self.results),
- exclude = exclude))
- file.close()
+ if self.regressions:
+ file = open(path.join(destination, "regressions.html"), 'w')
+ file.write(index.render(results = BuildHTMLIndex(self,
+ self.regressions),
+ page = 'regressions',
+ colnum = len(self.results),
+ links = links,
+ exclude = exclude))
+ file.close()
def _buildDictionary(self, summary):
# Build a dictionary from test name to pass count/total count, i.e.
diff --git a/templates/index.mako b/templates/index.mako
index e29ebcc..fd999ad 100644
--- a/templates/index.mako
+++ b/templates/index.mako
@@ -11,7 +11,7 @@
<h1>Result summary</h1>
<p>Currently showing: all</p>
<p>Show:
- % for i in ['index', 'changes', 'fixes', 'problems', 'regressions', 'skipped']:
+ % for i in links:
% if i == page:
${page}
% elif i == 'index':
@@ -23,7 +23,7 @@
% else:
<a href="${i}.html">${i}</a>
% endif
- % if i != "skipped":
+ % if i != links[-1]:
|
% endif
% endfor
--
1.8.1.4
More information about the Piglit
mailing list