[Piglit] [PATCH 10/12] HTML summary: Provides means to exclude generating test result files

Dylan Baker baker.dylan.c at gmail.com
Thu May 9 23:09:24 PDT 2013


This provides a switch and method for excluding the generation of the
test result HTML files (those that live under <testrun name>/). This
allows the user to trade some verbosity in the results for a significant
increase in generation speed. A run of quick.tests with all options
enabled takes ~5.5 seconds, with just pass and skip disabled it only
takes ~2.5 seconds. This only becomes more significant as more testsruns
are added the HTML page.

Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
 framework/summary.py   | 65 ++++++++++++++++++++++++++++----------------------
 piglit-summary-html.py | 15 +++++++++++-
 templates/index.mako   |  6 +++++
 3 files changed, 57 insertions(+), 29 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 122368b..5288543 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -586,7 +586,7 @@ class NewSummary:
                 if status[i] > 1 and status[i + 1] == 1:
                     self.fixes.append(test)
 
-    def generateHTML(self, destination):
+    def generateHTML(self, destination, exclude):
         """
         Produce HTML summaries.
 
@@ -637,27 +637,30 @@ class NewSummary:
                 # times!
                 tPath = path.join(destination, each.name, path.dirname(key))
 
-                # os.makedirs is very annoying, it throws an OSError if the
-                # path requested already exists, so do this check to esnure
-                # that it doesn't
-                if not path.exists(tPath):
-                    os.makedirs(tPath)
-
-                file = open(path.join(destination,
-                                      each.name,
-                                      key + ".html"),
-                            'w')
-                file.write(testfile.render(testname   = key,
-                                           status     = value['result'],
-                                           returncode = value['returncode'],
-                                           time       = value['time'],
-                                           info       = value['info'],
-                                           command    = value['command'],
-                                           css        = path.relpath(resultCss,
-                                                                     tPath),
-                                           index      = index))
-
-                file.close()
+                # Do not generate test result pages for skips
+                if value['result'] not in exclude:
+                    # os.makedirs is very annoying, it throws an OSError if
+                    # the path requested already exists, so do this check to
+                    # ensure that it doesn't
+                    if not path.exists(tPath):
+                        os.makedirs(tPath)
+
+                    file = open(path.join(destination,
+                                          each.name,
+                                          key + ".html"),
+                                'w')
+                    file.write(
+                        testfile.render(testname   = key,
+                                        status     = value['result'],
+                                        returncode = value['returncode'],
+                                        time       = value['time'],
+                                        info       = value['info'],
+                                        command    = value['command'],
+                                        css        = path.relpath(resultCss,
+                                                                  tPath),
+                                        index      = index))
+
+                    file.close()
 
         # Finally build the root html files: index, regressions, etc
         index = Template(filename = "templates/index.mako",
@@ -668,35 +671,40 @@ class NewSummary:
         file = open(path.join(destination, "index.html"), 'w')
         file.write(index.render(results = BuildHTMLIndex(self, self.alltests),
                                 page    = 'all',
-                                colnum  = len(self.results)))
+                                colnum  = len(self.results),
+                                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)))
+                                colnum  = len(self.results),
+                                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)))
+                                colnum  = len(self.results),
+                                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)))
+                                colnum  = len(self.results),
+                                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)))
+                                colnum  = len(self.results),
+                                exclude = exclude))
         file.close()
 
         # regressions.html
@@ -704,7 +712,8 @@ class NewSummary:
         file.write(index.render(results = BuildHTMLIndex(self,
                                                          self.regressions),
                                 page    = 'regressions',
-                                colnum  = len(self.results)))
+                                colnum  = len(self.results),
+                                exclude = exclude))
         file.close()
 
     def _buildDictionary(self, summary):
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index 2e1978c..8b34d97 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -46,6 +46,16 @@ def main():
     parser.add_argument("-l", "--list",
                         action  = "store",
                         help    = "Use test results from a list file")
+    parser.add_argument("-e", "--exclude-generation",
+                        default = [],
+                        action  = "append",
+                        choices = ['pass', 'warn', 'crash' 'fail', 'all'],
+                        help    = "Optionally exclude the generation of HTML"
+                                  "pages for individual test pages with the"
+                                  "status(es) given as arguments. This speeds"
+                                  "up HTML generation, but reduces the info"
+                                  "in the HTML pages. May be used multiple"
+                                  "times")
     parser.add_argument("summaryDir",
                         metavar = "<Summary Directory>",
                         help    = "Directory to put HTML files in")
@@ -55,6 +65,9 @@ def main():
                         help    = "Results files to include in HTML")
     args = parser.parse_args()
 
+    # If exclude-results has all, then change it to be all
+    if 'all' in args.exclude_generation:
+        args.exclude_generation=['skip', 'pass', 'warn', 'crash', 'fail']
 
     # if overwrite is requested delete the output directory
     if path.exists(args.summaryDir) and args.overwrite:
@@ -69,7 +82,7 @@ def main():
 
     # Create the HTML output
     output = summary.NewSummary(args.resultsFiles)
-    output.generateHTML(args.summaryDir)
+    output.generateHTML(args.summaryDir, args.exclude_generation)
 
 if __name__ == "__main__":
     main()
diff --git a/templates/index.mako b/templates/index.mako
index acc597d..e29ebcc 100644
--- a/templates/index.mako
+++ b/templates/index.mako
@@ -62,9 +62,15 @@
 					</td>
 				% elif line['type'] == "testResult":
 					<td class="${line['class']}">
+					## If the result is in the excluded results page list from
+					## argparse, just print the text, otherwise add the link
+					% if line['class'] not in exclude:
 						<a href="${line['href']}">
 							${line['text']}
 						</a>
+					% else:
+						${line['text']}
+					% endif
 					</td>
         % elif line['type'] == "subtestResult":
 					<td class="${line['class']}">
-- 
1.8.1.4



More information about the Piglit mailing list