diff options
author | nkozlovskiy <[email protected]> | 2023-08-17 14:46:47 +0300 |
---|---|---|
committer | nkozlovskiy <[email protected]> | 2023-08-17 17:10:15 +0300 |
commit | 6b27c58711cc34acf56dca10a90ff18d5d310f2c (patch) | |
tree | aa91e796d6e538d31cbe4b60d5be42f045feb6f1 /.github/scripts/tests/fail-checker.py | |
parent | 94b610e28ef001c9db9530909402f40fff14b356 (diff) |
ci: don't throw an error when empty report xml is found, also print failed test names
Diffstat (limited to '.github/scripts/tests/fail-checker.py')
-rwxr-xr-x | .github/scripts/tests/fail-checker.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/.github/scripts/tests/fail-checker.py b/.github/scripts/tests/fail-checker.py index f71f7f117be..78ec5a25c92 100755 --- a/.github/scripts/tests/fail-checker.py +++ b/.github/scripts/tests/fail-checker.py @@ -1,24 +1,30 @@ #!/usr/bin/env python3 import argparse -import glob -import os from typing import List -import xml.etree.ElementTree as ET +from junit_utils import iter_xml_files def check_for_fail(paths: List[str]): + failed_list = [] + error_list = [] for path in paths: - for fn in glob.glob(os.path.join(path, "*.xml")): - root = ET.parse(fn).getroot() - if root.tag != "testsuite": - suites = root.findall("testsuite") - else: - suites = [root] - - for suite in suites: - if int(suite.get("failures", 0)) > 0: - print(f"::error::You have failed tests") - raise SystemExit(-1) + for fn, suite, case in iter_xml_files(path): + is_failure = case.find("failure") is not None + is_error = case.find("error") is not None + test_name = f"{case.get('classname')}::{case.get('name')}" + + if is_failure: + failed_list.append((test_name, fn)) + elif is_error: + error_list.append((test_name, fn)) + + if failed_list or error_list: + print(f"::error::You have failed tests") + for t, fn in failed_list: + print(f"failure: {t} ({fn})") + for t, fn in error_list: + print(f"error: {t} ({fn})") + raise SystemExit(-1) def main(): |