If a FileNotFound exception occurs, log a simple message indicating the tests may
have not run.
This commit is contained in:
parent
f12afe0ef0
commit
314f32ed45
|
@ -13,32 +13,35 @@ print("::group::Arguments")
|
||||||
print(f"{sys.argv}")
|
print(f"{sys.argv}")
|
||||||
print("::endgroup::")
|
print("::endgroup::")
|
||||||
for xmlfile in xmlfiles:
|
for xmlfile in xmlfiles:
|
||||||
tree = ET.parse(xmlfile)
|
try:
|
||||||
|
tree = ET.parse(xmlfile)
|
||||||
|
|
||||||
root = tree.getroot()
|
root = tree.getroot()
|
||||||
name = root.attrib['name']
|
name = root.attrib['name']
|
||||||
time = root.attrib['time']
|
time = root.attrib['time']
|
||||||
tests = int(root.attrib['tests'])
|
tests = int(root.attrib['tests'])
|
||||||
skipped = int(root.attrib['skipped'])
|
skipped = int(root.attrib['skipped'])
|
||||||
errors = int(root.attrib['errors'])
|
errors = int(root.attrib['errors'])
|
||||||
failures = int(root.attrib['failures'])
|
failures = int(root.attrib['failures'])
|
||||||
success = tests - failures - errors - skipped
|
success = tests - failures - errors - skipped
|
||||||
total = tests - skipped
|
total = tests - skipped
|
||||||
print(f"::group::{name} {success}/{total} ({skipped} skipped) in {time}")
|
print(f"::group::{name} {success}/{total} ({skipped} skipped) in {time}")
|
||||||
|
|
||||||
for testcase in root:
|
for testcase in root:
|
||||||
if testcase.tag != "testcase":
|
if testcase.tag != "testcase":
|
||||||
continue
|
continue
|
||||||
testname = testcase.attrib['classname']
|
testname = testcase.attrib['classname']
|
||||||
message = testcase.attrib['name']
|
message = testcase.attrib['name']
|
||||||
time = testcase.attrib['time']
|
time = testcase.attrib['time']
|
||||||
child = testcase.find("failure")
|
child = testcase.find("failure")
|
||||||
if child is None:
|
if child is None:
|
||||||
print(f"{message} in {time}s")
|
print(f"{message} in {time}s")
|
||||||
else:
|
else:
|
||||||
print(f"::error file={testname}::{message} in {time}s")
|
print(f"::error file={testname}::{message} in {time}s")
|
||||||
print(child.text)
|
print(child.text)
|
||||||
body = f"passed={success} failures={failures} errors={errors} skipped={skipped}"
|
body = f" passed={success} failures={failures} errors={errors} skipped={skipped}"
|
||||||
print(f"::set-output name={suitename}::={body}")
|
print(f"::set-output name={suitename}::={body}")
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"::error::Unable to open test results file {xmlfile} - check if the tests completed")
|
||||||
print("::endgroup::")
|
print("::endgroup::")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue