Basically this patch replaces the returnList() function with os.path.relpath(), which can be used to return essentially the same output.
Signed-off-by: Dylan Baker <[email protected]> --- framework/summary.py | 116 ++++++++++++++------------------------------------- 1 file changed, 31 insertions(+), 85 deletions(-) diff --git a/framework/summary.py b/framework/summary.py index 25ee320..8215bbc 100644 --- a/framework/summary.py +++ b/framework/summary.py @@ -69,94 +69,40 @@ class HTMLIndex(list): generates a list of dicts that are passed to mako and turned into HTML """ - def returnList(open, close): - """ - As HTMLIndex iterates through the groups and tests it uses this - function to determine which groups to close (and thus reduce the - depth of the next write) and which ones to open (thus increasing - the depth) - - To that end one of two things happens, the path to the previous - group (close) and the next group (open) are equal, in that event we - don't want to open and close, becasue that will result in a - sawtooth pattern of a group with one test followed by the same - group with one test, over and over. Instead we simply return two - empty lists, which will result in writing a long list of test - results. The second option is that the paths are different, and - the function determines any commonality between the paths, and - returns the differences as close (the groups which are completly - written) and open (the new groups to write). - """ - common = [] - - # Open and close are lists, representing the group hierarchy, open - # being the groups that need are soon to be written, and close - # representing the groups that have finished writing. - if open == close: - return [], [] - else: - for i, j in izip_longest(open, close): - if i != j: - for k in common: - open.remove(k) - close.remove(k) - return open, close - else: - common.append(i) - # set a starting depth of 1, 0 is used for 'all' so 1 is the # next available group depth = 1 - - # Current dir is a list representing the groups currently being - # written. - currentDir = [] - - # Add the groups and tests to the out list - for key in sorted(page): - - # Split the group names and test names, then determine - # which groups to close and which to open - openList = key.split('/') - test = openList.pop() - openList, closeList = returnList(openList, list(currentDir)) - - # Close any groups in the close list - # for each group closed, reduce the depth by one - for i in reversed(closeList): - currentDir.remove(i) - depth -= 1 - - # Open new groups - for localGroup in openList: - self._newRow() - - # Add the left-most column: the name of the group - self._groupRow("head", depth, localGroup) - - # Add the group that we just opened to the currentDir, which - # will then be used to add that group to the HTML list. If - # there is a KeyError (the group doesn't exist), use (0, 0) - # which will get skip. This sets the group coloring correctly - currentDir.append(localGroup) - for each in summary.results: - # Decide which fields need to be updated - try: - self._groupResult(summary.fractions[each.name] - [path.join(*currentDir)], - summary.status[each.name] - [path.join(*currentDir)]) - except KeyError: - self._groupResult((0, 0), 'skip') - - # After each group increase the depth by one - depth += 1 - self._endRow() - - # Add the tests for the current group + group = "" + + # The following loop relies on alphabetical sorting of test names + for test in sorted(page): + + # If the current group not the same as the last group call + # os.path.relpath on it. This gives ".." for each group to close + # (reducing the depth) and a name for each group to open + # (increasing the depth) + if path.dirname(test) != group: + for cur in path.relpath(path.dirname(test), group).split('/'): + if cur == "..": + depth -= 1 + group = path.dirname(group) + else: + group = path.join(group, cur) + self._newRow() + self._groupRow("head", depth, group) + for each in summary.results: + try: + self._groupResult( + summary.fractions[each.name][group], + summary.status[each.name][group]) + except KeyError: + self._groupResult((0, 0), 'skip') + depth += 1 + self._endRow() + + # Finally add a new row for the test itself, and add the left-most + # name column self._newRow() - - # Add the left-most column: the name of the test self._testRow("group", depth, test) # Add the result from each test result to the HTML summary If there @@ -164,7 +110,7 @@ class HTMLIndex(list): # return Not Run, with clas skip for highlighting for each in summary.results: try: - self._testResult(each.name, key, each.tests[key]['result']) + self._testResult(each.name, test, each.tests[test]['result']) except KeyError: self.append({'type': 'other', 'text': '<td class="skip">Not Run</td>'}) -- 1.8.1.5 _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
