Merge branch 'ci/fix_single_dut_with_param' into 'master'

ci: fix test case markers when put targets as params

See merge request espressif/esp-idf!32703
This commit is contained in:
Fu Hanxi 2024-08-09 15:11:33 +08:00
commit 4d93ef0fe3
3 changed files with 28 additions and 2 deletions

View File

@ -4,6 +4,10 @@ components/esp_ringbuf/test_apps:
enable:
- if: IDF_TARGET in ["esp32", "esp32c3", "esp32s2"]
reason: covers all target types
disable_test:
- if: IDF_TARGET in ["esp32s2"]
temporary: true
reason: the other targets are not tested yet
depends_components:
- freertos
- esp_ringbuf

View File

@ -233,6 +233,12 @@ class IdfPytestEmbedded:
if 'all_targets' in item.keywords:
for _target in [*SUPPORTED_TARGETS, *PREVIEW_TARGETS]:
item.add_marker(_target)
# add single-dut "target" as param
_item_target_param = self.get_param(item, 'target', None)
if case.is_single_dut_test_case and _item_target_param and _item_target_param not in case.all_markers:
item.add_marker(_item_target_param)
items[:] = [_item for _item in items if _item in item_to_case_dict]
# 3.1. CollectMode.SINGLE_SPECIFIC, like `pytest --target esp32`

View File

@ -14,6 +14,13 @@ import pytest
def test_foo_single(dut):
pass
@pytest.mark.parametrize('target', [
'esp32',
'esp32c3',
])
def test_foo_single_with_param(dut):
pass
@pytest.mark.parametrize(
'count, target', [
(2, 'esp32|esp32s2'),
@ -38,8 +45,11 @@ def test_get_pytest_cases_single_specific(work_dirpath: Path) -> None:
script.write_text(TEMPLATE_SCRIPT)
cases = get_pytest_cases([str(work_dirpath)], 'esp32')
assert len(cases) == 1
assert len(cases) == 2
assert cases[0].targets == ['esp32']
assert cases[0].name == 'test_foo_single'
assert cases[1].targets == ['esp32']
assert cases[1].name == 'test_foo_single_with_param'
def test_get_pytest_cases_multi_specific(work_dirpath: Path) -> None:
@ -69,7 +79,7 @@ def test_get_pytest_cases_all(work_dirpath: Path) -> None:
script.write_text(TEMPLATE_SCRIPT)
cases = get_pytest_cases([str(work_dirpath)], CollectMode.ALL)
assert len(cases) == 6
assert len(cases) == 8
assert cases[0].targets == ['esp32', 'esp32s2']
assert cases[0].name == 'test_foo_multi'
@ -88,6 +98,12 @@ def test_get_pytest_cases_all(work_dirpath: Path) -> None:
assert cases[5].targets == ['esp32s2']
assert cases[5].name == 'test_foo_single'
assert cases[6].targets == ['esp32']
assert cases[6].name == 'test_foo_single_with_param'
assert cases[7].targets == ['esp32c3']
assert cases[7].name == 'test_foo_single_with_param'
def test_multi_with_marker_and_app_path(work_dirpath: Path) -> None:
script = work_dirpath / 'pytest_multi_with_marker_and_app_path.py'