[Piglit] [PATCH v2 10/11] HTML Summary: Don't generate empty pages

Kenneth Graunke kenneth at whitecape.org
Sat May 25 03:12:08 PDT 2013


On 05/17/2013 09:32 AM, Dylan Baker wrote:
> 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>

I'm not sure I like this.  One of my common working modes is:

1. Generate a summary with a few columns (say, xfb-1, xfb-2)
2. Open changes.html or regressions.html in my browser.
3. Notice that I had regressions.
4. Fix stuff, do a new run (say xfb-3)
5. Regenerate the summary with xfb-1 and xfb-3 only
6. Hit reload in my browser
7. Notice that there are no changes/regressions.

With this change, reloading will simply give me 404 error.  At that 
point, I don't know if (a) I had no regressions (good), or (b) html 
generation broke for some reason (i.e. bad JSON) and I didn't get any data.

Plus, then the only way to know that I have no changes/regressions is to 
load the index page (which has a TON of data and takes forever to load) 
and notice the links are missing.

So...yes, it does seem silly, but...it's kind of nice nonetheless.

> ---
>   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 722912c..6780458 100644
> --- a/framework/summary.py
> +++ b/framework/summary.py
> @@ -668,54 +668,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
>



More information about the Piglit mailing list