Skip to content

Commit

Permalink
Add xfail marking support to backend test runner (#3542)
Browse files Browse the repository at this point in the history
Signed-off-by: twata <twata@preferred.jp>

Co-authored-by: Ashwini Khade <askhade@microsoft.com>
  • Loading branch information
take-cheeze and askhade committed Jul 14, 2021
1 parent e7c8edc commit 2e5caf7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions onnx/backend/test/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, backend, parent_module=None): # type: (Type[Backend], Option
self._parent_module = parent_module
self._include_patterns = set() # type: Set[Pattern[Text]]
self._exclude_patterns = set() # type: Set[Pattern[Text]]
self._xfail_patterns = set() # type: Set[Pattern[Text]]

# This is the source of the truth of all test functions.
# Properties `test_cases`, `test_suite` and `tests` will be
Expand Down Expand Up @@ -94,6 +95,10 @@ def exclude(self, pattern): # type: (Text) -> Runner
self._exclude_patterns.add(re.compile(pattern))
return self

def xfail(self, pattern): # type: (Text) -> Runner
self._xfail_patterns.add(re.compile(pattern))
return self

def enable_report(self): # type: () -> Runner
import pytest # type: ignore

Expand All @@ -120,6 +125,9 @@ def _filtered_test_items(self): # type: () -> Dict[Text, Dict[Text, TestItem]]
'matched exclude pattern "{}"'.format(
exclude.pattern)
)(item.func)
for xfail in self._xfail_patterns:
if xfail.search(name):
item.func = unittest.expectedFailure(item.func)
filtered[category][name] = item
return filtered

Expand Down

0 comments on commit 2e5caf7

Please sign in to comment.