generated from SAP/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import subprocess | ||
from junit_xml import TestSuite, TestCase | ||
|
||
run_tests = True | ||
dump_test_output = False | ||
|
||
failure_message = "" | ||
|
||
def parse_report(report): | ||
res = [] | ||
for line in report.splitlines(): | ||
parsed = parse_line(line) | ||
if parsed: | ||
res.append(parsed) | ||
return TestSuite("Jstests", res) | ||
|
||
def parse_line(line): | ||
global failure_message | ||
|
||
parts = line.split(" | ") | ||
test_status = parts[0] | ||
|
||
if test_status not in ["TEST-PASS", "TEST-KNOWN-FAIL", "TEST-UNEXPECTED-FAIL"]: | ||
# Line is part of an failure message | ||
failure_message += line + "\n" | ||
return None | ||
|
||
time = float(line.split(("["))[1].split(" s")[0]) | ||
test_case = TestCase(parts[1], elapsed_sec=time) | ||
if test_status == "TEST-UNEXPECTED-FAIL": | ||
test_case.add_failure_info(output=failure_message) | ||
failure_message = "" | ||
|
||
return test_case | ||
|
||
|
||
# Execute Jstests | ||
|
||
if run_tests: | ||
result = subprocess.run(["../../../mach", "jstests", "--tinderbox"], capture_output=True) | ||
|
||
data = result.stdout.decode("utf-8") | ||
|
||
if dump_test_output: | ||
with open("dump.txt", "w+") as f: | ||
f.write(data) | ||
else: | ||
data = open("dump.txt").read() | ||
|
||
tests = parse_report(data) | ||
|
||
with open("output.xml", "w") as f: | ||
TestSuite.to_file(f, [tests]) | ||
|