Skip to content

Commit

Permalink
feat: flexible choices for run_all_single_board_cases
Browse files Browse the repository at this point in the history
  • Loading branch information
horw committed Apr 26, 2024
1 parent 6075710 commit ffa19cb
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions pytest-embedded-idf/pytest_embedded_idf/unity_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ def run_all_single_board_cases(
reset: bool = False,
timeout: float = 30,
run_ignore_cases: bool = False,
names: list = (),
) -> None:
"""
Run all single board cases, including multi_stage cases, and normal cases
Expand All @@ -431,14 +432,34 @@ def run_all_single_board_cases(
reset: whether to perform a hardware reset before running a case
timeout: timeout. (Default: 30 seconds)
run_ignore_cases: run ignored test cases or not
names: run test case by test names
"""

inverted = group and group.startswith('!')

def invert(condition):
if inverted:
return not condition
return condition

group = group and group.lstrip('!')

for case in self.test_menu:
if not group or group in case.groups:
if not case.is_ignored or run_ignore_cases:
if case.type == 'normal':
self._run_normal_case(case, reset=reset, timeout=timeout)
elif case.type == 'multi_stage':
self._run_multi_stage_case(case, reset=reset, timeout=timeout)
should_run = False
if not group and not names:
should_run = True
if group and invert(group in case.groups):
should_run = True
if names and case.name in names:
should_run = True

if not should_run:
continue
if not case.is_ignored or run_ignore_cases:
if case.type == 'normal':
self._run_normal_case(case, reset=reset, timeout=timeout)
elif case.type == 'multi_stage':
self._run_multi_stage_case(case, reset=reset, timeout=timeout)


class _MultiDevTestDut:
Expand Down

0 comments on commit ffa19cb

Please sign in to comment.