Skip to content

Instantly share code, notes, and snippets.

@driazati
Created April 8, 2022 17:56
Show Gist options
  • Save driazati/f636700cd68b5717350c107a0eaaee4e to your computer and use it in GitHub Desktop.
Save driazati/f636700cd68b5717350c107a0eaaee4e to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euxo pipefail
curl -L "$1" > main_report.xml
curl -L "$2" > shard_report.xml
python list_tests.py --no-details --file main_report.xml | sort > main.log
python list_tests.py --no-details --file shard_report.xml | sort > shard.log
git add main.log -f
mv shard.log main.log
git diff main.log
import argparse
from pathlib import Path
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")
parser.add_argument(
"--no-details", action="store_true", help="skip test case details"
)
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 = []
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
if not args.no_details:
node_id += " " + case.status.cdata + " " + block
tests.append(node_id)
for nodeid in tests:
print(nodeid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment