|
11 | 11 | import traceback |
12 | 12 |
|
13 | 13 | import pexpect |
| 14 | +import yaml |
14 | 15 |
|
15 | 16 | print_log_names = False |
16 | 17 | real_stdout = sys.stdout |
@@ -947,6 +948,32 @@ def __enter__(self): |
947 | 948 | def __exit__(self, _type, _value, _traceback): |
948 | 949 | self.gdb.pop_state() |
949 | 950 |
|
| 951 | + |
| 952 | +def load_excluded_tests(excluded_tests_file, target_name): |
| 953 | + result = [] |
| 954 | + if excluded_tests_file is None or len(excluded_tests_file) == 0: |
| 955 | + return result |
| 956 | + |
| 957 | + target_excludes = {} |
| 958 | + with open(excluded_tests_file) as file: |
| 959 | + raw_data = yaml.safe_load(file) |
| 960 | + for (target, test_list) in raw_data.items(): |
| 961 | + if not isinstance(test_list, list): |
| 962 | + raise ValueError(f"Target {target!r} does not contain a test list", excluded_tests_file, test_list) |
| 963 | + if not all(isinstance(s, str) for s in test_list): |
| 964 | + raise ValueError(f"Not every element in the target test list {target!r} is a string", |
| 965 | + excluded_tests_file, test_list) |
| 966 | + |
| 967 | + target_excludes.update(raw_data) |
| 968 | + |
| 969 | + if target_name in target_excludes: |
| 970 | + result += target_excludes[target_name] |
| 971 | + if "all" in target_excludes: |
| 972 | + result += target_excludes["all"] |
| 973 | + |
| 974 | + return result |
| 975 | + |
| 976 | + |
950 | 977 | def run_all_tests(module, target, parsed): |
951 | 978 | todo = [] |
952 | 979 | for name in dir(module): |
@@ -985,6 +1012,9 @@ def run_all_tests(module, target, parsed): |
985 | 1012 | todo.insert(0, ("ExamineTarget", ExamineTarget, None)) |
986 | 1013 | examine_added = True |
987 | 1014 |
|
| 1015 | + excluded_tests = load_excluded_tests(parsed.exclude_tests, target.name) |
| 1016 | + target.skip_tests += excluded_tests |
| 1017 | + |
988 | 1018 | results, count = run_tests(parsed, target, todo) |
989 | 1019 |
|
990 | 1020 | header(f"ran {count} tests in {time.time() - overall_start:.0f}s", dash=':') |
@@ -1065,6 +1095,8 @@ def add_test_run_options(parser): |
1065 | 1095 | parser.add_argument("--misaval", |
1066 | 1096 | help="Don't run ExamineTarget, just assume the misa value which is " |
1067 | 1097 | "specified.") |
| 1098 | + parser.add_argument("--exclude-tests", |
| 1099 | + help="Specify yaml file listing tests to exclude") |
1068 | 1100 |
|
1069 | 1101 | def header(title, dash='-', length=78): |
1070 | 1102 | if title: |
|
0 commit comments