forked from espressif/esp-idf
fix(test): Proper cleanup after build_custom_cmake pytest
The test create build folder in current directory which in this case is defined by (test_app_copy). It also creates sdkconfig file in cmake source directory, which is defined as $IDF_PATH/examples/build_system/cmake/idf_as_lib The fixtures ensures proper cleanup even when test fails.
This commit is contained in:
@@ -16,6 +16,9 @@ from test_build_system_helpers import run_cmake
|
|||||||
from test_build_system_helpers import run_cmake_and_build
|
from test_build_system_helpers import run_cmake_and_build
|
||||||
|
|
||||||
|
|
||||||
|
# This test checks multiple targets in one test function. It would be better to have each target
|
||||||
|
# tested in a isolated test case, but that would mean doing idf_copy each time, and copying takes most of the time
|
||||||
|
@pytest.mark.usefixtures('idf_copy')
|
||||||
def test_build_custom_cmake_project(test_app_copy: Path) -> None:
|
def test_build_custom_cmake_project(test_app_copy: Path) -> None:
|
||||||
# Test is compatible with any target. Random targets in the list are selected for performance reasons
|
# Test is compatible with any target. Random targets in the list are selected for performance reasons
|
||||||
idf_path = Path(os.environ['IDF_PATH'])
|
idf_path = Path(os.environ['IDF_PATH'])
|
||||||
@@ -30,12 +33,15 @@ def test_build_custom_cmake_project(test_app_copy: Path) -> None:
|
|||||||
)
|
)
|
||||||
assert file_contains((test_app_copy / 'build' / 'compile_commands.json'), '"command"')
|
assert file_contains((test_app_copy / 'build' / 'compile_commands.json'), '"command"')
|
||||||
shutil.rmtree(test_app_copy / 'build')
|
shutil.rmtree(test_app_copy / 'build')
|
||||||
|
os.remove(idf_path / 'examples' / 'build_system' / 'cmake' / 'idf_as_lib' / 'sdkconfig')
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skipif(
|
@pytest.mark.skipif(
|
||||||
sys.platform == 'win32',
|
sys.platform == 'win32',
|
||||||
reason='On Win project is not buildable without system compiler on the host machine. (Win CI runners)',
|
reason='On Win project is not buildable without system compiler on the host machine. (Win CI runners)',
|
||||||
)
|
)
|
||||||
|
@pytest.mark.usefixtures('idf_copy')
|
||||||
|
@pytest.mark.usefixtures('test_app_copy')
|
||||||
def test_build_custom_cmake_project_host() -> None:
|
def test_build_custom_cmake_project_host() -> None:
|
||||||
logging.info('Test build ESP-IDF as a library to a custom CMake projects for host')
|
logging.info('Test build ESP-IDF as a library to a custom CMake projects for host')
|
||||||
idf_path = Path(os.environ['IDF_PATH'])
|
idf_path = Path(os.environ['IDF_PATH'])
|
||||||
|
Reference in New Issue
Block a user