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:
Frantisek Hrbata
2025-11-04 07:48:12 +01:00
parent 21a030b0d5
commit a317a422da
3 changed files with 32 additions and 0 deletions
+13
View File
@@ -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))