[Piglit] [PATCH 08/16] piglit-summary-junit.py: Use NewSummary.generateJUnit
Dylan Baker
baker.dylan.c at gmail.com
Thu Jun 13 08:36:15 PDT 2013
Stop using the old JUnit generation code, and start using the new code.
Signed-off-by: Dylan Baker <baker.dylan.c at gmail.com>
---
piglit-summary-junit.py | 84 +++----------------------------------------------
1 file changed, 4 insertions(+), 80 deletions(-)
diff --git a/piglit-summary-junit.py b/piglit-summary-junit.py
index e6dd699..fdc54a4 100755
--- a/piglit-summary-junit.py
+++ b/piglit-summary-junit.py
@@ -28,84 +28,9 @@ import argparse
import os
import sys
-sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
-import framework.core
-import framework.summary
-from framework import junit
-
-
-class Writer:
-
- def __init__(self, filename):
- self.report = junit.Report(filename)
- self.path = []
-
- def write(self, arg):
- results = [framework.core.loadTestResults(arg)]
- summary = framework.summary.Summary(results)
-
- self.report.start()
- self.report.startSuite('piglit')
- try:
- for test in summary.allTests():
- self.write_test(summary, test)
- finally:
- self.enter_path([])
- self.report.stopSuite()
- self.report.stop()
-
- def write_test(self, summary, test):
- 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:
- try:
- self.report.addStdout(result['command'] + '\n')
- except KeyError:
- pass
+import framework.summary as summary
- try:
- self.report.addStderr(result['info'])
- except KeyError:
- pass
-
- success = result.get('result')
- if success in ('pass', 'warn'):
- pass
- elif success == 'skip':
- self.report.addSkipped()
- else:
- self.report.addFailure(success)
-
- try:
- duration = float(result['time'])
- except KeyError:
- pass
- finally:
- self.report.stopCase(duration)
-
- def enter_path(self, path):
- ancestor = 0
- try:
- while self.path[ancestor] == path[ancestor]:
- ancestor += 1
- except IndexError:
- pass
-
- for dirname in self.path[ancestor:]:
- self.report.stopSuite()
-
- for dirname in path[ancestor:]:
- self.report.startSuite(dirname)
-
- self.path = path
+sys.path.append(os.path.dirname(os.path.realpath(sys.argv[0])))
def main():
@@ -121,9 +46,8 @@ def main():
help = "JSON results file to be converted")
args = parser.parse_args()
-
- writer = Writer(args.output)
- writer.write(args.testResults)
+ output = summary.NewSummary([args.testResults])
+ output.generateJUnit(args.output)
if __name__ == "__main__":
--
1.8.1.4
More information about the Piglit
mailing list