mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
ci: apply idf-ci 1.x
(cherry picked from commit 21d772a24da646bfb672418cf056199cad9b17e4)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
import os
|
||||
import typing as t
|
||||
@@ -9,6 +9,7 @@ import pytest
|
||||
import yaml
|
||||
from _pytest.config import Config
|
||||
from _pytest.python import Function
|
||||
from _pytest.python import Metafunc
|
||||
from _pytest.runner import CallInfo
|
||||
from dynamic_pipelines.constants import KNOWN_GENERATE_TEST_CHILD_PIPELINE_WARNINGS_FILEPATH
|
||||
from idf_ci import IdfPytestPlugin
|
||||
@@ -114,6 +115,55 @@ class IdfLocalPlugin:
|
||||
|
||||
return item.callspec.params.get(key, default) or default
|
||||
|
||||
@staticmethod
|
||||
def _has_parametrized_arg(metafunc: Metafunc, arg_name: str) -> bool:
|
||||
for marker in metafunc.definition.iter_markers(name='parametrize'):
|
||||
if not marker.args:
|
||||
continue
|
||||
|
||||
argnames = marker.args[0]
|
||||
if isinstance(argnames, str):
|
||||
names = [name.strip() for name in argnames.split(',')]
|
||||
else:
|
||||
names = list(argnames)
|
||||
|
||||
if arg_name in names:
|
||||
return True
|
||||
|
||||
for callspec in getattr(metafunc, '_calls', []):
|
||||
if arg_name in callspec.params:
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _is_linux_target_run(config: Config) -> bool:
|
||||
target = config.getoption('target')
|
||||
if not target:
|
||||
return False
|
||||
|
||||
if isinstance(target, str):
|
||||
targets = [_t.strip() for _t in target.split(',')]
|
||||
else:
|
||||
targets = [str(_t).strip() for _t in target]
|
||||
|
||||
return 'linux' in targets
|
||||
|
||||
@pytest.hookimpl(trylast=True)
|
||||
def pytest_generate_tests(self, metafunc: Metafunc) -> None:
|
||||
if 'embedded_services' not in metafunc.fixturenames:
|
||||
return
|
||||
|
||||
if self._has_parametrized_arg(metafunc, 'embedded_services'):
|
||||
return
|
||||
|
||||
if metafunc.definition.get_closest_marker('qemu') is not None:
|
||||
metafunc.parametrize('embedded_services', ['idf,qemu'], indirect=True)
|
||||
return
|
||||
|
||||
if self._is_linux_target_run(metafunc.config):
|
||||
metafunc.parametrize('embedded_services', ['idf'], indirect=True)
|
||||
|
||||
@pytest.hookimpl(wrapper=True)
|
||||
def pytest_collection_modifyitems(self, config: Config, items: t.List[Function]) -> t.Generator[None, None, None]:
|
||||
yield # throw it back to idf-ci
|
||||
|
||||
Reference in New Issue
Block a user