forked from PhilippvK/etiss_riscv_test_env
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_messages.py
48 lines (37 loc) · 1.71 KB
/
gen_messages.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import git
import argparse
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument("directory")
parser.add_argument("--print-passed", action="store_true")
parser.add_argument("--allow-empty", action="store_true")
parser.add_argument("--allow-fail", action="store_true")
parser.add_argument("--allow-err", action="store_true")
args = parser.parse_args()
directory = Path(args.directory)
with open(directory / "fail.txt", "r") as f:
fail_content = f.readlines()
with open(directory / "pass.txt", "r") as f:
pass_content = f.readlines()
pass_content = [line.strip() for line in pass_content if len(line.strip()) > 0]
fail_content = [line.strip() for line in fail_content if len(line.strip()) > 0]
err_content = [line for line in fail_content if "etiss error" in line or "timeout" in line]
fail_content = [line for line in fail_content if "etiss error" not in line and "timeout" not in line]
num_pass = len(pass_content)
num_err = len(err_content)
num_fail = len(fail_content)
if num_err > 0:
err_tests = [test.split(":", 1)[0] for test in err_content]
print("::error ::", num_err, "test(s) crashed:", ", ".join(err_tests))
if num_fail > 0:
fail_tests = [test.split(":", 1)[0] for test in fail_content]
print("::warning ::", num_fail, "test(s) failed:", ", ".join(fail_tests))
if num_pass > 0 and args.print_passed:
pass_tests = [test.split(":", 1)[0] for test in pass_content]
print("::notice ::", num_pass, "test(s) passed:", ", ".join(pass_tests))
if num_pass + num_fail + num_err == 0:
assert args.allow_empty, "No test results found"
if num_err > 0:
assert args.allow_err, "Crashing tests not allowed"
if num_fail > 0:
assert args.allow_fail, "Failing tests not allowed"