Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to parse jstests output #158

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions js/src/tests/parse_output.py
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])