Created
April 26, 2022 17:46
-
-
Save driazati/ba261f806a1194cc53d8986aec7a9fb0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python3 | |
import argparse | |
import subprocess | |
import textwrap | |
import json | |
import junitparser | |
from pathlib import Path | |
REPO_ROOT = Path(__file__).resolve().parent.parent.parent | |
def lstrip(s: str, prefix: str) -> str: | |
if s.startswith(prefix): | |
s = s[len(prefix) :] | |
return s | |
def classname_to_file(classname: str) -> str: | |
classname = lstrip(classname, "cython.") | |
classname = lstrip(classname, "ctypes.") | |
return classname.replace(".", "/") + ".py" | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser( | |
description="Wrap TVM CI scripts and output helpful information on failures" | |
) | |
parser.add_argument("--file", default="report.xml", help="xml report file") | |
args, other = parser.parse_known_args() | |
import untangle | |
file_path = Path(args.file) | |
if not file_path.exists(): | |
raise RuntimeError(f"'{file_path}' file doesn't exist") | |
obj = untangle.parse(str(file_path)) | |
tests = [] | |
import rich | |
datas = {} | |
for suite in obj.testResult.suite: | |
for case in suite.case: | |
if case.status.cdata == 'SKIPPED': | |
continue | |
block = " / ".join(reversed([x.cdata for x in suite.enclosingBlockName])) | |
node_id = classname_to_file(case.className.cdata) + "::" + case.name.cdata | |
node_id += " " + case.status.cdata + " " + block | |
duration = float(case.duration.cdata) | |
tests.append((node_id, duration)) | |
tests = sorted(tests, key=lambda x: x[1]) | |
for nodeid, duration in reversed(tests): | |
print(duration, nodeid) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment