mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-03 03:31:41 +03:00
feat(test_build_system): add buildv2_skip marker
This marker enables the skipping of tests that, for any reason, cannot be executed with the IDF build system version 2. It accepts an optional string argument that explains why the test cannot be run with version 2. If no explanation is provided, a default message is used. This marker is used in the `pytest_collection_modifyitems` hook to skip tests marked with it when the `--buildv2` pytest command line option is used. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -10,7 +10,10 @@ from pathlib import Path
|
||||
from tempfile import mkdtemp
|
||||
|
||||
import pytest
|
||||
from _pytest.config import Config
|
||||
from _pytest.fixtures import FixtureRequest
|
||||
from _pytest.main import Session
|
||||
from _pytest.nodes import Item
|
||||
from test_build_system_helpers import EXT_IDF_PATH
|
||||
from test_build_system_helpers import EnvDict
|
||||
from test_build_system_helpers import IdfPyFunc
|
||||
@@ -235,3 +238,13 @@ def idf_py(default_idf_env: EnvDict) -> IdfPyFunc:
|
||||
return run_idf_py(*args, env=default_idf_env, workdir=os.getcwd(), check=check, input_str=input_str) # type: ignore
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def pytest_collection_modifyitems(session: Session, config: Config, items: list[Item]) -> None:
|
||||
if not config.getoption('--buildv2', False):
|
||||
return
|
||||
for item in items:
|
||||
marker = item.get_closest_marker('buildv2_skip')
|
||||
if marker:
|
||||
reason = marker.args[0] if marker.args else 'Skipped as this test is specific to build system v1.'
|
||||
item.add_marker(pytest.mark.skip(reason=reason))
|
||||
|
||||
Reference in New Issue
Block a user