diff options
author | José Fonseca <jfonseca@vmware.com> | 2012-01-26 10:52:28 +0000 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2012-01-26 10:52:28 +0000 |
commit | 1c880ee09c7d616b7094e5a1a5952e4376b3cf86 (patch) | |
tree | 17aed526f195fcc2ec57ab0d5cb9eb0fb42fb865 /piglit-summary-junit.py | |
parent | 4fc7df8d97ba7e24edbb365ea87b26d23d73f436 (diff) |
jenkins: Improve test grouping.
Use the testsuite/class hierarchy such that the piglit test groups are
better preserved in HTML renderered by Jenkins.
Diffstat (limited to 'piglit-summary-junit.py')
-rwxr-xr-x | piglit-summary-junit.py | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/piglit-summary-junit.py b/piglit-summary-junit.py index 9cfc06f2..0696f325 100755 --- a/piglit-summary-junit.py +++ b/piglit-summary-junit.py @@ -39,52 +39,56 @@ class Writer: self.report = junit.Report(filename) self.path = [] - def write(self, args): - results = [framework.core.loadTestResults(arg) for arg in args] + 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): - self.enter_path(test.path.split('/')) - for j in range(len(summary.testruns)): - tr = summary.testruns[j] - tr_name, _ = tr.name.rsplit('.', 1) - result = test.results[j] - - self.report.startCase(tr_name) - duration = None + 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: - try: - self.report.addStdout(result['command'] + '\n') - except KeyError: - pass - - try: - self.report.addStderr(result['info']) - except KeyError: - pass - - success = result.get('result') - if success == 'pass': - 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) + self.report.addStdout(result['command'] + '\n') + except KeyError: + pass + + try: + self.report.addStderr(result['info']) + except KeyError: + pass + + success = result.get('result') + if success == 'pass': + 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 @@ -105,7 +109,7 @@ class Writer: def main(): optparser = optparse.OptionParser( - usage="\n\t%prog [options] [test.results] ...", + usage="\n\t%prog [options] test.results", version="%%prog") optparser.add_option( '-o', '--output', metavar='FILE', @@ -113,12 +117,12 @@ def main(): help="output filename") (options, args) = optparser.parse_args(sys.argv[1:]) - if not args: + if len(args) != 1: optparser.error('need to specify one test result') usage() writer = Writer(options.output) - writer.write(args) + writer.write(args[0]) if __name__ == "__main__": |