# [Piglit] [PATCH 1/2] core: generate a summary of regressions

Marek Olšák maraeo at gmail.com
Mon Apr 4 15:36:49 PDT 2011

```This is basically a subset of 'changes'.

The regression is if a test result changes from either 'pass' or 'skip'
to something other than 'pass' and 'skip'. Thus the relation is:

{ pass, skip } -> { warn, fail, trap, abort, crash }
---
framework/summary.py   |   21 ++++++++++++++++++---
piglit-summary-html.py |    6 +++++-
2 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/framework/summary.py b/framework/summary.py
index 8938509..133d6c5 100644
--- a/framework/summary.py
+++ b/framework/summary.py
@@ -52,6 +52,17 @@ class PassVector:
##### number of testruns
#############################################################################
class TestSummary:
+	def isRegression(self, statiList):
+		# Regression is:
+		# - if an item is neither 'pass' nor 'skip'
+		# - and if any item on the left side thereof is 'pass' or 'skip'
+		for i in range(1, len(statiList)):
+			if statiList[i-1] == 'pass' or statiList[i-1] == 'skip':
+				for j in range(i, len(statiList)):
+					if statiList[j] != 'pass' and statiList[j] != 'skip':
+						return True
+		return False
+
def __init__(self, summary, path, name, results):
"""\
summary is the root summary object
@@ -86,9 +97,11 @@ results is an array of TestResult instances, one per testrun

result.passvector = vectormap[result.status]

-		stati = set([result.status for result in results])
-		self.changes = len(stati) > 1
-		self.problems = len(stati - set(['pass', 'skip'])) > 0
+		statiList = [result.status for result in results]
+		statiSet = set(statiList)
+		self.changes = len(statiSet) > 1
+		self.problems = len(statiSet - set(['pass', 'skip'])) > 0
+		self.regressions = self.isRegression(statiList)

def allTests(self):
return [self]
@@ -110,6 +123,7 @@ results is an array of GroupResult instances, one per testrun
self.results = results[:]
self.changes = False
self.problems = False
+		self.regressions = False
self.children = {}

# Perform some initial annotations
@@ -154,6 +168,7 @@ results is an array of GroupResult instances, one per testrun

self.changes = self.changes or self.children[name].changes
self.problems = self.problems or self.children[name].problems
+				self.regressions = self.regressions or self.children[name].regressions

def allTests(self):
"""\
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index 2fd7fb7..30a049e 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -75,7 +75,8 @@ Testrun = readfile(os.path.join(templatedir, 'testrun.html'))
SummaryPages = {
'all': 'index.html',
'changes': 'changes.html',
-	'problems': 'problems.html'
+	'problems': 'problems.html',
+	'regressions': 'regressions.html'
}

def buildDetailValue(detail):
@@ -192,6 +193,8 @@ def buildGroupSummary(indent, groupsummary, showcurrent):
names = filter(lambda n: groupsummary.children[n].changes, names)
elif showcurrent == 'problems':
names = filter(lambda n: groupsummary.children[n].problems, names)
+	elif showcurrent == 'regressions':
+		names = filter(lambda n: groupsummary.children[n].regressions, names)

names.sort()
for n in names:
@@ -325,6 +328,7 @@ def main():
writeSummaryHtml(summary, summaryDir, 'all')
writeSummaryHtml(summary, summaryDir, 'problems')
writeSummaryHtml(summary, summaryDir, 'changes')
+	writeSummaryHtml(summary, summaryDir, 'regressions')

if __name__ == "__main__":
--
1.7.1

```