[Piglit] [PATCH 2/3] summary.py: Treat subtests as groups, again

Dylan Baker baker.dylan.c at gmail.com
Thu Apr 24 17:20:41 PDT 2014


With this patch tests with subtests are treated as groups, their status
is thrown away, and they inherit the 'worst' status from their children
just like a group.

This reverts commit de4b13de226e140313c3571e59a57438626da183.
---
 framework/summary.py | 86 ++++++++++++++++++++++++++++++++++++++++++----------
 templates/index.mako |  2 +-
 2 files changed, 71 insertions(+), 17 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 47138bf..4436cea 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -163,8 +163,17 @@ class HTMLIndex(list):
             # is a KeyError (a result doesn't contain a particular test),
             # return Not Run, with clas skip for highlighting
             for each in summary.results:
+                # If the "group" at the top of the key heirachy contains
+                # 'subtest' then it is really not a group, link to that page
                 try:
-                    self._testResult(each.name, key, each.tests[key]['result'])
+                    if each.tests[path.dirname(key)]['subtest']:
+                        href = path.dirname(key)
+                except KeyError:
+                    href = key
+
+                try:
+                    self._testResult(each.name, href,
+                                     summary.status[each.name][key])
                 except KeyError:
                     self.append({'type': 'other',
                                  'text': '<td class="skip">Not Run</td>'})
@@ -223,9 +232,17 @@ class HTMLIndex(list):
         displaying pass/fail/crash/etc and formatting the cell to the
         correct color.
         """
+        # "Not Run" is not a valid class, if it apears set the class to skip
+        if text == so.NOTRUN:
+            css = 'skip'
+            href = None
+        else:
+            css = text
+            href = path.join(group, href + ".html")
+
         self.append({'type': 'testResult',
-                     'class': text,
-                     'href': path.join(group, href + ".html"),
+                     'class': css,
+                     'href': href,
                      'text': text})
 
 
@@ -265,7 +282,12 @@ class Summary:
             """ Helper for updating the fractions and status lists """
             fraction[test] = tuple(
                 [sum(i) for i in zip(fraction[test], result.fraction)])
-            if result != so.SKIP and status[test] < result:
+
+            # If the new status is worse update it, or if the new status is
+            # SKIP (which is equivalent to notrun) and the current is NOTRUN
+            # update it
+            if (status[test] < result or 
+                    (result == so.SKIP and status[test] == so.NOTRUN)):
                 status[test] = result
 
         for results in self.results:
@@ -282,6 +304,10 @@ class Summary:
             fraction = self.fractions[results.name]
             status = self.status[results.name]
 
+            # store the results to be appeneded to results. Adding them in the
+            # loop will cause a RuntimeError
+            temp_results = {}
+
             for key, value in results.tests.iteritems():
                 # if the first character of key is a / then our while loop will
                 # become an infinite loop. Beyond that / should never be the
@@ -289,18 +315,46 @@ class Summary:
                 # test profiles.
                 assert key[0] != '/'
 
-                #FIXME: Add subtest support
-
-                # Walk the test name as if it was a path, at each level update
-                # the tests passed over the total number of tests (fractions),
-                # and update the status of the current level if the status of
-                # the previous level was worse, but is not skip
-                while key != '':
-                    fgh(key, value['result'])
-                    key = path.dirname(key)
-
-                # when we hit the root update the 'all' group and stop
-                fgh('all', value['result'])
+                # Treat a test with subtests as if it is a group, assign the
+                # subtests' statuses and fractions down to the test, and then
+                # proceed like normal.
+                if 'subtest' in value:
+                    for (subt, subv) in value['subtest'].iteritems():
+                        subt = path.join(key, subt)
+                        subv = so.status_lookup(subv)
+
+                        # Add the subtest to the fractions and status lists
+                        fraction[subt] = subv.fraction
+                        status[subt] = subv
+                        temp_results.update({subt: {'result': subv}})
+
+                        self.tests['all'].add(subt)
+                        while subt != '':
+                            fgh(subt, subv)
+                            subt = path.dirname(subt)
+                        fgh('all', subv)
+
+                    # remove the test from the 'all' list, this will cause to
+                    # be treated as a group
+                    self.tests['all'].discard(key)
+                else:
+                    # Walk the test name as if it was a path, at each level
+                    # update the tests passed over the total number of tests
+                    # (fractions), and update the status of the current level
+                    # if the status of the previous level was worse, but is not
+                    # skip
+                    while key != '':
+                        fgh(key, value['result'])
+                        key = path.dirname(key)
+
+                    # when we hit the root update the 'all' group and stop
+                    fgh('all', value['result'])
+
+            # Update the the results.tests dictionary with the subtests so that
+            # they are entered into the appropriate pages other than all.
+            # Updating it in the loop will raise a RuntimeError
+            for key, value in temp_results.iteritems():
+                results.tests[key] = value
 
         # Create the lists of statuses like problems, regressions, fixes,
         # changes and skips
diff --git a/templates/index.mako b/templates/index.mako
index e959a27..1ca46d3 100644
--- a/templates/index.mako
+++ b/templates/index.mako
@@ -60,7 +60,7 @@
           <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:
+          % if line['class'] not in exclude and line['href'] is not None:
             <a href="${line['href']}">
               ${line['text']}
             </a>
-- 
2.0.0.rc0



More information about the Piglit mailing list