|
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 |
@@ -944,6 +945,32 @@ def __enter__(self): |
944 | 945 | def __exit__(self, _type, _value, _traceback): |
945 | 946 | self.gdb.pop_state() |
946 | 947 |
|
| 948 | + |
| 949 | +def load_excluded_tests(excluded_tests_file, target_name): |
| 950 | + result = [] |
| 951 | + if excluded_tests_file is None or len(excluded_tests_file) == 0: |
| 952 | + return result |
| 953 | + |
| 954 | + target_excludes = {} |
| 955 | + with open(excluded_tests_file) as file: |
| 956 | + raw_data = yaml.safe_load(file) |
| 957 | + for (target, test_list) in raw_data.items(): |
| 958 | + if not isinstance(test_list, list): |
| 959 | + raise ValueError(f"Target {target!r} does not contain a test list", excluded_tests_file, test_list) |
| 960 | + if not all(isinstance(s, str) for s in test_list): |
| 961 | + raise ValueError(f"Not every element in the target test list {target!r} is a string", |
| 962 | + excluded_tests_file, test_list) |
| 963 | + |
| 964 | + target_excludes.update(raw_data) |
| 965 | + |
| 966 | + if target_name in target_excludes: |
| 967 | + result += target_excludes[target_name] |
| 968 | + if "all" in target_excludes: |
| 969 | + result += target_excludes["all"] |
| 970 | + |
| 971 | + return result |
| 972 | + |
| 973 | + |
947 | 974 | def run_all_tests(module, target, parsed): |
948 | 975 | todo = [] |
949 | 976 | for name in dir(module): |
@@ -982,6 +1009,9 @@ def run_all_tests(module, target, parsed): |
982 | 1009 | todo.insert(0, ("ExamineTarget", ExamineTarget, None)) |
983 | 1010 | examine_added = True |
984 | 1011 |
|
| 1012 | + excluded_tests = load_excluded_tests(parsed.exclude_tests, target.name) |
| 1013 | + target.skip_tests += excluded_tests |
| 1014 | + |
985 | 1015 | results, count = run_tests(parsed, target, todo) |
986 | 1016 |
|
987 | 1017 | header(f"ran {count} tests in {time.time() - overall_start:.0f}s", dash=':') |
@@ -1068,6 +1098,8 @@ def add_test_run_options(parser): |
1068 | 1098 | parser.add_argument("--misaval", |
1069 | 1099 | help="Don't run ExamineTarget, just assume the misa value which is " |
1070 | 1100 | "specified.") |
| 1101 | + parser.add_argument("--exclude-tests", |
| 1102 | + help="Specify yaml file listing tests to exclude") |
1071 | 1103 |
|
1072 | 1104 | def header(title, dash='-', length=78): |
1073 | 1105 | if title: |
|
0 commit comments