ci: add test marks linter

This commit is contained in:
igor.udot
2024-12-02 10:47:32 +08:00
parent 47df2ed524
commit bbcef0570d
13 changed files with 663 additions and 30 deletions

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
"""
Pytest Related Constants. Don't import third-party packages here.
@@ -16,7 +16,18 @@ from idf_ci_utils import IDF_PATH
from idf_ci_utils import idf_relpath
from pytest_embedded.utils import to_list
SUPPORTED_TARGETS = ['esp32', 'esp32s2', 'esp32c3', 'esp32s3', 'esp32c2', 'esp32c6', 'esp32h2', 'esp32p4', 'esp32c5', 'esp32c61']
SUPPORTED_TARGETS = [
'esp32',
'esp32s2',
'esp32c3',
'esp32s3',
'esp32c2',
'esp32c6',
'esp32h2',
'esp32p4',
'esp32c5',
'esp32c61',
]
PREVIEW_TARGETS: t.List[str] = [] # this PREVIEW_TARGETS excludes 'linux' target
DEFAULT_SDKCONFIG = 'default'
DEFAULT_LOGDIR = 'pytest-embedded'
@@ -30,6 +41,8 @@ TARGET_MARKERS = {
'esp32c5': 'support esp32c5 target',
'esp32c6': 'support esp32c6 target',
'esp32h2': 'support esp32h2 target',
'esp32h4': 'support esp32h4 target', # as preview
'esp32h21': 'support esp32h21 target', # as preview
'esp32p4': 'support esp32p4 target',
'esp32c61': 'support esp32c61 target',
'linux': 'support linux target',
@@ -174,6 +187,7 @@ class PytestApp:
"""
Pytest App with relative path to IDF_PATH
"""
def __init__(self, path: str, target: str, config: str) -> None:
self.path = idf_relpath(path)
self.target = target
@@ -215,8 +229,10 @@ class PytestCase:
for _t in [app.target for app in self.apps]:
if _t in self.target_markers:
skip = False
warnings.warn(f'`pytest.mark.[TARGET]` defined in parametrize for multi-dut test cases is deprecated. ' # noqa: W604
f'Please use parametrize instead for test case {self.item.nodeid}')
warnings.warn(
f'`pytest.mark.[TARGET]` defined in parametrize for multi-dut test cases is deprecated. ' # noqa: W604
f'Please use parametrize instead for test case {self.item.nodeid}'
)
break
if not skip:
@@ -238,7 +254,7 @@ class PytestCase:
return {marker.name for marker in self.item.iter_markers()}
@property
def target_markers(self) -> t.Set[str]:
def skip_targets(self) -> t.Set[str]:
def _get_temp_markers_disabled_targets(marker_name: str) -> t.Set[str]:
temp_marker = self.item.get_closest_marker(marker_name)
@@ -260,11 +276,15 @@ class PytestCase:
# in CI we skip the union of `temp_skip` and `temp_skip_ci`
if os.getenv('CI_JOB_ID'):
skip_targets = temp_skip_ci_targets.union(temp_skip_targets)
_skip_targets = temp_skip_ci_targets.union(temp_skip_targets)
else: # we use `temp_skip` locally
skip_targets = temp_skip_targets
_skip_targets = temp_skip_targets
return {marker for marker in self.all_markers if marker in TARGET_MARKERS} - skip_targets
return _skip_targets
@property
def target_markers(self) -> t.Set[str]:
return {marker for marker in self.all_markers if marker in TARGET_MARKERS} - self.skip_targets
@property
def env_markers(self) -> t.Set[str]:
@@ -285,10 +305,7 @@ class PytestCase:
if 'jtag' in self.env_markers or 'usb_serial_jtag' in self.env_markers:
return True
cases_need_elf = [
'panic',
'gdbstub_runtime'
]
cases_need_elf = ['panic', 'gdbstub_runtime']
for case in cases_need_elf:
if any(case in Path(app.path).parts for app in self.apps):