From dc813d91eadaa05248558a2c0b05af7988ca18b0 Mon Sep 17 00:00:00 2001 From: Renz Bagaporo Date: Fri, 17 Jul 2026 16:19:15 +0900 Subject: [PATCH] test(build_system): fix buildv2 pytest coverage Allow the reconfigure test to assert the buildv2 activation message when pytest runs with --buildv2. Make the ULP API probe use CMake-friendly forward-slash paths and an explicit ULP toolchain/custom-toolchain setting so the direct cmake configure works on Windows as well as Linux. --- tools/test_build_system/buildv2/test_ulp.py | 19 +++++++++++++------ tools/test_build_system/test_common.py | 7 +++++-- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/test_build_system/buildv2/test_ulp.py b/tools/test_build_system/buildv2/test_ulp.py index 29bfc6cf918..6d01da2e583 100644 --- a/tools/test_build_system/buildv2/test_ulp.py +++ b/tools/test_build_system/buildv2/test_ulp.py @@ -23,6 +23,10 @@ LEGACY_PROJECT_APIS = ( ALL_APIS = FULL_PROJECT_APIS + LEGACY_PROJECT_APIS +def _cmake_path(path: Path) -> str: + return path.resolve().as_posix() + + def _write_api_probe_project(project_dir: Path, entry_point: str, add_native_executable: bool) -> None: native_executable = 'add_executable(${ULP_APP_NAME} main.c)' if add_native_executable else '' if entry_point.endswith('ulp_project.cmake'): @@ -112,24 +116,27 @@ def test_ulp_cmake_api_availability( build_dir = tmp_path / 'build' project_dir.mkdir() _write_api_probe_project(project_dir, entry_point, add_native_executable) + ulp_cmake_dir = idf_path / 'components' / 'ulp' / 'cmake' cmake_args = ( 'cmake', '-G', 'Ninja', '-S', - str(project_dir), + _cmake_path(project_dir), '-B', - str(build_dir), - f'-DCMAKE_MODULE_PATH={idf_path / "components" / "ulp" / "cmake"}', - f'-DIDF_PATH={idf_path}', + _cmake_path(build_dir), + f'-DCMAKE_MODULE_PATH={_cmake_path(ulp_cmake_dir)}', + f'-DCMAKE_TOOLCHAIN_FILE={_cmake_path(ulp_cmake_dir / "toolchain-lp-core-riscv.cmake")}', + f'-DIDF_PATH={_cmake_path(idf_path)}', '-DIDF_TARGET=esp32c6', - f'-DSDKCONFIG_CMAKE={project_dir / "sdkconfig.cmake"}', - f'-DSDKCONFIG_HEADER={project_dir / "sdkconfig.h"}', + f'-DSDKCONFIG_CMAKE={_cmake_path(project_dir / "sdkconfig.cmake")}', + f'-DSDKCONFIG_HEADER={_cmake_path(project_dir / "sdkconfig.h")}', '-D__ULP_BUILD=1', '-DULP_APP_NAME=ulp_api_probe', '-DULP_TYPE=lp_core', '-DIDF_BUILD_V2=y', + '-DIDF_CUSTOM_TOOLCHAIN=1', ) result = subprocess.run( cmake_args, diff --git a/tools/test_build_system/test_common.py b/tools/test_build_system/test_common.py index c715c457ff1..f1d056a7fe0 100644 --- a/tools/test_build_system/test_common.py +++ b/tools/test_build_system/test_common.py @@ -72,9 +72,12 @@ def get_subdirs_absolute_paths(path: Path) -> list[str]: @pytest.mark.usefixtures('test_app_copy') @pytest.mark.test_app_copy('examples/get-started/blink') -def test_compile_commands_json_updated_by_reconfigure(idf_py: IdfPyFunc) -> None: +def test_compile_commands_json_updated_by_reconfigure(idf_py: IdfPyFunc, request: pytest.FixtureRequest) -> None: output = idf_py('reconfigure') - assert 'Building ESP-IDF components for target esp32' in output.stdout + if request.config.getoption('buildv2', False): + assert 'IDF Build System V2 (cmakev2) activated' in output.stdout + else: + assert 'Building ESP-IDF components for target esp32' in output.stdout snapshot_1 = get_snapshot(['build/compile_commands.json']) snapshot_2 = get_snapshot(['build/compile_commands.json']) snapshot_2.assert_same(snapshot_1)