|
7 | 7 | import os |
8 | 8 | import pathlib |
9 | 9 | import platform |
10 | | -from typing import List |
| 10 | +import sys |
| 11 | +from typing import Dict, List |
11 | 12 |
|
12 | 13 | from defusedxml.ElementTree import parse |
13 | 14 |
|
@@ -93,6 +94,30 @@ def get_warnings(reports_path: pathlib.Path, suite: str) -> List[TestWarning]: |
93 | 94 | return [TestWarning(location=next(iter(w.keys())), message=next(iter(w.values()))) for w in warnings_data] |
94 | 95 |
|
95 | 96 |
|
| 97 | +def get_missing_tests(warnings: List[TestWarning]) -> List[str]: |
| 98 | + """Searches warnings for PytestSelectWarning and returns a list of missing tests.""" |
| 99 | + tests = set() |
| 100 | + for warning in warnings: |
| 101 | + if 'PytestSelectWarning: pytest-select: Not all deselected' not in warning.message: |
| 102 | + continue |
| 103 | + for line in warning.message.splitlines(): |
| 104 | + if line.startswith(' - '): |
| 105 | + tests.add(line.removeprefix(' - ')) |
| 106 | + return sorted(list(tests)) |
| 107 | + |
| 108 | + |
| 109 | +def get_all_missing_tests(reports_path: pathlib.Path) -> Dict[str, List[str]]: |
| 110 | + """Returns missing tests for all suites.""" |
| 111 | + all_missing_tests = {} |
| 112 | + for report in reports_path.glob('*.xml'): |
| 113 | + suite = report.stem |
| 114 | + warnings = get_warnings(reports_path, suite) |
| 115 | + missing_tests = get_missing_tests(warnings) |
| 116 | + if missing_tests: |
| 117 | + all_missing_tests[suite] = missing_tests |
| 118 | + return all_missing_tests |
| 119 | + |
| 120 | + |
96 | 121 | def parse_report(report_path: pathlib.Path, skiplist_dir: pathlib.Path) -> ReportStats: |
97 | 122 | """Parses the specified report.""" |
98 | 123 | stats = ReportStats(name=report_path.stem) |
@@ -219,6 +244,15 @@ def main(): |
219 | 244 | args.report_path = pathlib.Path(args.reports) |
220 | 245 | args.skiplist_dir = pathlib.Path( |
221 | 246 | args.skip_list if args.skip_list else os.getenv('TRITON_TEST_SKIPLIST_DIR', 'scripts/skiplist/default')) |
| 247 | + |
| 248 | + missing_tests = get_all_missing_tests(args.report_path) |
| 249 | + if missing_tests: |
| 250 | + for suite, tests in missing_tests.items(): |
| 251 | + print(f'# Missing tests in {suite}:') |
| 252 | + for test in tests: |
| 253 | + print(test) |
| 254 | + sys.exit(1) |
| 255 | + |
222 | 256 | stats = parse_reports(args) |
223 | 257 |
|
224 | 258 | if args.suite == 'all': |
|
0 commit comments