diff options
author | José Fonseca <jfonseca@vmware.com> | 2013-10-14 18:04:30 -0700 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2013-10-14 18:05:20 -0700 |
commit | 8ad3f4d0b2db6142b13311513c4120316630e940 (patch) | |
tree | 1c2c8067807135f0b37fa0c7782ffd449bd440e3 | |
parent | a0ce346612334f1e8653925158d6c2160573bde8 (diff) |
junit: Update script for status class hierarchy.
Also, remove all the summary stuff, which we never used.
-rwxr-xr-x | piglit-summary-junit.py | 249 |
1 files changed, 9 insertions, 240 deletions
diff --git a/piglit-summary-junit.py b/piglit-summary-junit.py index d9e4b9c2e..8962c5346 100755 --- a/piglit-summary-junit.py +++ b/piglit-summary-junit.py @@ -30,236 +30,10 @@ import sys sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0]))) import framework.core as core +import framework.status as status from framework import junit -class PassVector: - """ - Vector indicting the number of tests that have a particular status, - pass/fail/skip/etc. - """ - - def __init__(self, p, w, f, s, c): - self.passnr = p - self.warnnr = w - self.failnr = f - self.skipnr = s - self.crashnr = c - - def add(self, o): - self.passnr += o.passnr - self.warnnr += o.warnnr - self.failnr += o.failnr - self.skipnr += o.skipnr - self.crashnr += o.crashnr - - -class TestSummary: - """ - Summarize the results for one test across a number of testruns - """ - 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 -path is the path to the group (e.g. shaders/glean-fragProg1) -name is the display name of the group (e.g. glean-fragProg1) -results is an array of TestResult instances, one per testrun -""" - self.summary = summary - self.path = path - self.name = name - self.results = results[:] - - for j in range(len(self.results)): - result = self.results[j] - result.testrun = self.summary.testruns[j] - result.status = '' - if 'result' in result: - result.status = result['result'] - - vectormap = { - 'pass': PassVector(1,0,0,0,0), - 'warn': PassVector(0,1,0,0,0), - 'fail': PassVector(0,0,1,0,0), - 'skip': PassVector(0,0,0,1,0), - 'crash': PassVector(0,0,0,0,1) - } - - if result.status not in vectormap: - result.status = 'warn' - - result.passvector = vectormap[result.status] - - 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) - statiList.reverse() - self.fixes = self.isRegression(statiList) - self.skipped = 'skip' in statiSet - - def allTests(self): - return [self] - - -class GroupSummary: - """ - Summarize a group of tests - """ - def createDummyGroup(self, result, test_name): - new_group = core.GroupResult() - new_group[' ' + test_name + '(All Tests)'] = result[test_name] - result[test_name] = new_group - - def __init__(self, summary, path, name, results): - """\ -summary is the root summary object -path is the path to the group (e.g. shaders/glean-fragProg1) -name is the display name of the group (e.g. glean-fragProg1) -results is an array of GroupResult instances, one per testrun -""" - self.summary = summary - self.path = path - self.name = name - self.results = results[:] - self.changes = False - self.problems = False - self.regressions = False - self.fixes = False - self.skipped = False - self.children = {} - - # Perform some initial annotations - for j in range(len(self.results)): - result = self.results[j] - result.passvector = PassVector(0, 0, 0, 0, 0) - result.testrun = self.summary.testruns[j] - - # Collect, create and annotate children - for result in self.results: - for name in result: - if name in self.children: - continue - - childpath = name - if len(self.path) > 0: - childpath = self.path + '/' + childpath - - if isinstance(result[name], core.GroupResult): - # This loop checks to make sure that all results - # with the same 'name' are of the same type. - # This is necessary to handle the case where - # a testname in an earlier result (an earlier - # result in this case means a result that - # comes before the current result in self.results) - # denotes a test group but in a later - # result it denotes a single test case, for example: - # - # result 0: - # test/group/a PASS - # test/group/b PASS - # test/group/c PASS - # result 1: - # test/group PASS - for r in self.results: - if name in r and not isinstance(r[name], core.GroupResult): - self.createDummyGroup(r, name) - - childresults = [r.get(name, core.GroupResult()) - for r in self.results] - - self.children[name] = GroupSummary( - summary, - childpath, - name, - childresults - ) - else: - # We need to check and handle the reversed case - # described in the above comment e.g.: - # result 0: - # test/group PASS - # result 1: - # test/group/a PASS - # test/group/b PASS - # test/group/c PASS - need_group = 0 - for r in self.results: - if name in r and not isinstance(r[name], core.TestResult): - need_group = 1 - if need_group: - for r in self.results: - if name in r and isinstance(r[name], core.TestResult): - self.createDummyGroup(r, name) - childresults = [r.get(name, core.GroupResult()) - for r in self.results] - - self.children[name] = GroupSummary( - summary, - childpath, - name, - childresults - ) - else: - childresults = [r.get(name, core.TestResult({ 'result': 'skip' })) - for r in self.results] - self.children[name] = TestSummary( - summary, - childpath, - name, - childresults - ) - - for j in range(len(self.results)): - self.results[j].passvector.add(childresults[j].passvector) - - 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 - self.fixes = self.fixes or self.children[name].fixes - self.skipped = self.skipped or self.children[name].skipped - - def allTests(self): - """\ -Returns an array of all child TestSummary instances. -""" - return [t for name in self.children for t in self.children[name].allTests()] - - -class Summary: - """ - Summarize an array of testruns - """ - def __init__(self, testruns): - """\ -testruns is an array of TestrunResult instances -""" - groups = [ - core.GroupResult.make_tree(testrun.tests) - for testrun in testruns - ] - self.testruns = testruns - self.root = GroupSummary(self, '', 'All', groups) - - def allTests(self): - """\ -Returns an array of all child TestSummary instances. -""" - return self.root.allTests() - - class Writer: def __init__(self, filename): @@ -267,28 +41,23 @@ class Writer: self.path = [] def write(self, arg): - results = [core.loadTestResults(arg)] - summary = Summary(results) + testrun = core.loadTestResults(arg) self.report.start() self.report.startSuite('piglit') try: - for test in summary.allTests(): - self.write_test(summary, test) + for (path, result) in testrun.tests.items(): + self.write_test(testrun, path, result) finally: self.enter_path([]) self.report.stopSuite() self.report.stop() - def write_test(self, summary, test): - test_path = test.path.split('/') + def write_test(self, testrun, test_path, result): + test_path = test_path.split('/') test_name = test_path.pop() self.enter_path(test_path) - assert len(summary.testruns) == 1 - tr = summary.testruns[0] - result = test.results[0] - self.report.startCase(test_name) duration = None try: @@ -303,12 +72,12 @@ class Writer: pass success = result.get('result') - if success in ('pass', 'warn'): + if success in (status.Pass(), status.Warn()): pass - elif success == 'skip': + elif success == status.Skip(): self.report.addSkipped() else: - self.report.addFailure(success) + self.report.addFailure(success.name) try: duration = float(result['time']) |