mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 03:00:34 +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:
@@ -131,6 +131,24 @@ def test_idf_copy(idf_copy):
|
||||
run_idf_py('build', env=env)
|
||||
```
|
||||
|
||||
### `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. For implementation details,
|
||||
please refer to `conftest.py`.
|
||||
|
||||
```python
|
||||
@pytest.mark.buildv2_skip
|
||||
def test_target_guessing()
|
||||
|
||||
@pytest.mark.buildv2_skip('This functionality has not been implemented in cmakev2 yet.')
|
||||
def test_target_guessing()
|
||||
```
|
||||
|
||||
### Build snapshots
|
||||
|
||||
`get_snapshot(list_of_globs)` function takes a list of glob expressions, finds the files matching these expressions, and returns a `Snapshot` instance. `Snapshot` instances record file names and their modification timestamps. Two `Snapshot` instances can be compared using `assert_same` and `assert_different` methods:
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -21,3 +21,4 @@ markers =
|
||||
idf_copy_with_space: ensures that destination directory where IDF is copied contain space
|
||||
force_temp_work_dir: force temporary folder as the working directory
|
||||
with_idf_components: automatically create/delete components under IDF_PATH
|
||||
buildv2_skip: mark the test to run only when the --buildv2 command line option is not used
|
||||
|
||||
Reference in New Issue
Block a user