From: Alfredo Deza Date: Wed, 6 Jan 2016 16:44:25 +0000 (-0500) Subject: spit out junit X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1d0eea9c200202b1dabd46e68724fcb6d6e38583;p=ceph-build.git spit out junit Signed-off-by: Alfredo Deza --- diff --git a/ceph-pr-commits/build/build b/ceph-pr-commits/build/build index c5b18af2..7c737334 100644 --- a/ceph-pr-commits/build/build +++ b/ceph-pr-commits/build/build @@ -20,6 +20,24 @@ returncode = process.wait() stdout = process.stdout.read() stderr = process.stderr.read() + +def produce_junit(**kw): + time = kw.get('time', 0) + tests = kw.get('tests', []) + failures = kw.get('failures', []) + total_tests = len(tests) + total_failures = len(failures) + template = """ + + + + """.format(total_failures=total_failures, total_tests=total_tests) + path = os.path.join(os.getenv("$WORKSPACE", ""), 'report.xml') + print template + with open(path, 'w') as junit_file: + junit_file.write(template) + + def extract_sha(lines): trim = lines.split() for i in trim: @@ -27,9 +45,17 @@ def extract_sha(lines): return i # git log output goes to stdout so process that +tests = [] +failures = [] for chunk in stdout.split('\n\ncommit'): # we are interested in every commit chunk if not chunk: continue + tests.append(1) if not 'Signed-off-by:' in chunk: sha = extract_sha(chunk) - raise SystemExit('A commit is missing "Signed-off-by". sha: %s' % sha) + failures.append(sha) + +produce_junit(tests=tests, failures=failures) + +if failures: + raise SystemExit('A commit is missing "Signed-off-by". sha: %s' % sha)