aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornkozlovskiy <nmk@ydb.tech>2023-08-17 14:46:47 +0300
committernkozlovskiy <nmk@ydb.tech>2023-08-17 17:10:15 +0300
commit6b27c58711cc34acf56dca10a90ff18d5d310f2c (patch)
treeaa91e796d6e538d31cbe4b60d5be42f045feb6f1
parent94b610e28ef001c9db9530909402f40fff14b356 (diff)
downloadydb-6b27c58711cc34acf56dca10a90ff18d5d310f2c.tar.gz
ci: don't throw an error when empty report xml is found, also print failed test names
-rw-r--r--.github/actions/test/action.yml2
-rwxr-xr-x.github/scripts/tests/fail-checker.py34
-rwxr-xr-x.github/scripts/tests/generate-summary.py25
-rw-r--r--.github/scripts/tests/junit_utils.py28
4 files changed, 50 insertions, 39 deletions
diff --git a/.github/actions/test/action.yml b/.github/actions/test/action.yml
index 1d07532c34..0c4f3039fc 100644
--- a/.github/actions/test/action.yml
+++ b/.github/actions/test/action.yml
@@ -305,4 +305,4 @@ runs:
- name: finish
shell: bash
run: |
- .github/scripts/tests/fail-checker.py $TESTREPDIR/unittests/ $TESTREPDIR/suites/ \ No newline at end of file
+ .github/scripts/tests/fail-checker.py $TESTREPDIR/unittests/ $TESTREPDIR/suites/ $PYTESTREPDIR/ \ No newline at end of file
diff --git a/.github/scripts/tests/fail-checker.py b/.github/scripts/tests/fail-checker.py
index f71f7f117b..78ec5a25c9 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():
diff --git a/.github/scripts/tests/generate-summary.py b/.github/scripts/tests/generate-summary.py
index e7dbca46eb..33d61b01f1 100755
--- a/.github/scripts/tests/generate-summary.py
+++ b/.github/scripts/tests/generate-summary.py
@@ -1,12 +1,10 @@
#!/usr/bin/env python3
import argparse
import os
-import glob
import dataclasses
import sys
from typing import Optional, List
-from xml.etree import ElementTree as ET
-from junit_utils import get_property_value
+from junit_utils import get_property_value, iter_xml_files
@dataclasses.dataclass
@@ -33,27 +31,6 @@ class SummaryEntry:
return "?"
-def iter_xml_files(folder_or_file):
- if os.path.isfile(folder_or_file):
- files = [folder_or_file]
- else:
- files = glob.glob(os.path.join(folder_or_file, "*.xml"))
-
- for fn in files:
- tree = ET.parse(fn)
- root = tree.getroot()
-
- if root.tag == "testsuite":
- suites = [root]
- elif root.tag == "testsuites":
- suites = root.findall("testsuite")
- else:
- raise ValueError(f"Invalid root tag {root.tag}")
- for suite in suites:
- for case in suite.findall("testcase"):
- yield fn, suite, case
-
-
def parse_junit(folder_or_file):
result = []
for fn, suite, case in iter_xml_files(folder_or_file):
diff --git a/.github/scripts/tests/junit_utils.py b/.github/scripts/tests/junit_utils.py
index cca04b2521..fd636884cf 100644
--- a/.github/scripts/tests/junit_utils.py
+++ b/.github/scripts/tests/junit_utils.py
@@ -1,3 +1,5 @@
+import os
+import glob
from xml.etree import ElementTree as ET
@@ -63,3 +65,29 @@ def suite_case_iterator(root):
for case in suite.findall("testcase"):
cls, method = case.attrib["classname"], case.attrib["name"]
yield suite, case, cls, method
+
+
+def iter_xml_files(folder_or_file):
+ if os.path.isfile(folder_or_file):
+ files = [folder_or_file]
+ else:
+ files = glob.glob(os.path.join(folder_or_file, "*.xml"))
+
+ for fn in files:
+ try:
+ tree = ET.parse(fn)
+ except ET.ParseError as e:
+ print(f"Unable to parse {fn}: {e}")
+ continue
+
+ root = tree.getroot()
+
+ if root.tag == "testsuite":
+ suites = [root]
+ elif root.tag == "testsuites":
+ suites = root.findall("testsuite")
+ else:
+ raise ValueError(f"Invalid root tag {root.tag}")
+ for suite in suites:
+ for case in suite.findall("testcase"):
+ yield fn, suite, case