Skip to content

Commit a061d26

Browse files
authored
Add check for missing tests in skip list (#3199)
A command line option `--select-fail-on-missing` for `pytest-select` does not work with `pytest-xdist`: the error message is cryptic and does no contain the list of missing tests, so we removed this option. There are missing tests in our skip lists so we need to return the check for missing tests back and fix the skip lists. We collect test warnings to `{suite}-warnings.json` and `pytest-select` issues a warning `PytestSelectWarning` with the list of missing tests. We use this warning to show the list of missing tests and stop a workflow with error.
1 parent 1f73581 commit a061d26

File tree

4 files changed

+91
-118
lines changed

4 files changed

+91
-118
lines changed

scripts/pass_rate.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
import os
88
import pathlib
99
import platform
10-
from typing import List
10+
import sys
11+
from typing import Dict, List
1112

1213
from defusedxml.ElementTree import parse
1314

@@ -93,6 +94,30 @@ def get_warnings(reports_path: pathlib.Path, suite: str) -> List[TestWarning]:
9394
return [TestWarning(location=next(iter(w.keys())), message=next(iter(w.values()))) for w in warnings_data]
9495

9596

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+
96121
def parse_report(report_path: pathlib.Path, skiplist_dir: pathlib.Path) -> ReportStats:
97122
"""Parses the specified report."""
98123
stats = ReportStats(name=report_path.stem)
@@ -219,6 +244,15 @@ def main():
219244
args.report_path = pathlib.Path(args.reports)
220245
args.skiplist_dir = pathlib.Path(
221246
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+
222256
stats = parse_reports(args)
223257

224258
if args.suite == 'all':

scripts/skiplist/lts/debug.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
https://github.com/intel/intel-xpu-backend-for-triton/issues/2755
1+
# https://github.com/intel/intel-xpu-backend-for-triton/issues/2755
22
test/unit/test_debug.py::test_device_assert[True-True-True-False]
33
test/unit/test_debug.py::test_device_assert[True-False-None-False]
44
test/unit/test_debug.py::test_device_assert[False-True-True-False]

0 commit comments

Comments
 (0)