feat(tools): add pytest mark idf_copy_with_space

This commit is contained in:
Marek Fiala 2024-08-15 11:53:48 +02:00
parent f0e8966ca5
commit ccbb415be8
5 changed files with 15 additions and 7 deletions

View File

@ -114,6 +114,8 @@ Note, `default_idf_env` sets up the environment based on the `IDF_PATH` environm
Copies IDF from `IDF_PATH` into a new temporary directory. `@pytest.mark.idf_copy('name prefix')` can be used to specify the name prefix of the temporary directory.
The marker `@pytest.mark.idf_copy_with_space` can be used in combination with `idf_copy` fixture to create a temporary directory with a space in the name.
For the duration of the test, `IDF_PATH` environment variable is set to the newly created copy.
```python

View File

@ -157,6 +157,10 @@ def test_git_template_app(func_work_dir: Path, request: FixtureRequest) -> typin
@pytest.fixture
def idf_copy(func_work_dir: Path, request: FixtureRequest) -> typing.Generator[Path, None, None]:
copy_to = request.node.name + '_idf'
# allow overriding the destination via pytest.mark.idf_copy_with_space so the destination contain space
mark_with_space = request.node.get_closest_marker('idf_copy_with_space')
if mark_with_space:
copy_to = request.node.name + ' idf'
# allow overriding the destination via pytest.mark.idf_copy()
mark = request.node.get_closest_marker('idf_copy')

View File

@ -13,7 +13,9 @@ junit_family = xunit1
junit_logging = stdout
junit_log_passing_tests = False
## !! When adding new markers, don't forget to update also the tools\test_build_system\README.md !!
markers =
test_app_copy: specify relative path of the app to copy, and the prefix of the destination directory name
idf_copy: specify the prefix of the destination directory where IDF should be copied
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

View File

@ -79,7 +79,7 @@ def test_kconfig_deprecated_options(idf_py: IdfPyFunc, test_app_copy: Path) -> N
@pytest.mark.usefixtures('idf_copy')
@pytest.mark.idf_copy('test_kconfig_variouos_options')
@pytest.mark.idf_copy('test_kconfig_various_options')
def test_kconfig_multiple_and_target_specific_options(idf_py: IdfPyFunc, test_app_copy: Path) -> None:
idf_path = Path(os.environ['IDF_PATH'])

View File

@ -21,7 +21,7 @@ def clean_app_dir(app_path: Path) -> None:
shutil.rmtree(app_path / 'build', ignore_errors=True)
@pytest.mark.idf_copy('esp idf with spaces')
@pytest.mark.idf_copy_with_space
def test_spaces_bundle1(idf_copy: Path) -> None:
logging.info('Running test spaces bundle 1')
# test spiffsgen
@ -32,7 +32,7 @@ def test_spaces_bundle1(idf_copy: Path) -> None:
run_idf_py('-DIDF_TARGET=esp32s2', 'build', workdir=(idf_copy / 'examples' / 'system' / 'ulp' / 'ulp_riscv' / 'gpio'))
@pytest.mark.idf_copy('esp idf with spaces')
@pytest.mark.idf_copy_with_space
def test_spaces_bundle2(idf_copy: Path) -> None:
logging.info('Running test spaces bundle 2')
# test flash_encryption
@ -41,7 +41,7 @@ def test_spaces_bundle2(idf_copy: Path) -> None:
run_idf_py('build', workdir=(idf_copy / 'examples' / 'protocols' / 'https_x509_bundle'))
@pytest.mark.idf_copy('esp idf with spaces')
@pytest.mark.idf_copy_with_space
def test_spaces_bundle3(idf_copy: Path) -> None:
logging.info('Running test spaces bundle 3')
secure_boot_app_path = (idf_copy / 'tools' / 'test_apps' / 'security' / 'secure_boot')
@ -67,7 +67,7 @@ def test_spaces_bundle3(idf_copy: Path) -> None:
# Dummy parameter with a space in it, used so that the test directory name contains a space
pytest.param('test spaces')
])
@pytest.mark.idf_copy('esp idf with spaces')
@pytest.mark.idf_copy_with_space
@pytest.mark.usefixtures('idf_copy')
def test_spaces_bundle4(dummy_: str, idf_py: IdfPyFunc, test_app_copy: Path) -> None:
logging.info(f'Running test spaces bundle 4 in {test_app_copy}')
@ -83,7 +83,7 @@ def test_spaces_bundle4(dummy_: str, idf_py: IdfPyFunc, test_app_copy: Path) ->
@pytest.mark.skipif(sys.platform == 'win32', reason='Unix test')
@pytest.mark.idf_copy('esp idf with spaces')
@pytest.mark.idf_copy_with_space
def test_install_export_unix(idf_copy: Path) -> None:
logging.info('install and export setup scripts')
env = dict(**os.environ)
@ -100,7 +100,7 @@ def test_install_export_unix(idf_copy: Path) -> None:
@pytest.mark.skipif(sys.platform != 'win32', reason='Windows test')
@pytest.mark.idf_copy('esp idf with spaces')
@pytest.mark.idf_copy_with_space
def test_install_export_win(idf_copy: Path) -> None:
logging.info('install and export setup scripts')
env = dict(**os.environ)