From f72292b0d7bfdb1a99db0d5c6af009df19722a16 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Mon, 17 Nov 2025 12:07:48 +0530 Subject: [PATCH] test(cmakev2): Enable test_rebuild.py for buildv2 CI tests The test_rebuild_no_changes test verifies that running idf.py build successively without any file changes results in identical build artifacts on the second run (i.e., nothing gets rebuilt). This test was failing in buildv2 because it expected kconfig_menus.json to be present in build/config/ after a normal build. However, in cmakev2, kconfig_menus.json is not generated during regular builds. In cmakev1, kconfig_menus.json was generated globally during every build alongside other config files (sdkconfig.h, sdkconfig.cmake, etc). In cmakev2, kconfig_menus.json generation does not happend for normal builds because it depends on the Kconfig menu hierarchy and cannot be generated globally. It must be generated per-executable. Hence, this commit updates the artefacts list for cmakev2 to not expect the kconfig_menus.json file during a build/re-build action. --- .gitlab/ci/build.yml | 1 + .gitlab/ci/test-win.yml | 1 + .../test_build_system_helpers/__init__.py | 37 ++++++++++++++----- .../build_constants.py | 22 +++++++---- tools/test_build_system/test_rebuild.py | 10 +++-- 5 files changed, 50 insertions(+), 21 deletions(-) diff --git a/.gitlab/ci/build.yml b/.gitlab/ci/build.yml index 2f3af19eba..a4d09b9d8d 100644 --- a/.gitlab/ci/build.yml +++ b/.gitlab/ci/build.yml @@ -287,6 +287,7 @@ pytest_buildv2_system: test_components.py test_cmake.py test_idf_extension.py + test_rebuild.py pytest_build_system_macos: extends: diff --git a/.gitlab/ci/test-win.yml b/.gitlab/ci/test-win.yml index 7785cce377..2eceab04ba 100644 --- a/.gitlab/ci/test-win.yml +++ b/.gitlab/ci/test-win.yml @@ -179,3 +179,4 @@ pytest_buildv2_system_win: test_components.py test_cmake.py test_idf_extension.py + test_rebuild.py diff --git a/tools/test_build_system/test_build_system_helpers/__init__.py b/tools/test_build_system/test_build_system_helpers/__init__.py index 57c6493e74..d5166e7a1e 100644 --- a/tools/test_build_system/test_build_system_helpers/__init__.py +++ b/tools/test_build_system/test_build_system_helpers/__init__.py @@ -1,6 +1,8 @@ -# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 from .build_constants import ALL_ARTIFACTS +from .build_constants import ALL_ARTIFACTS_BUILDV1 +from .build_constants import ALL_ARTIFACTS_BUILDV2 from .build_constants import APP_BINS from .build_constants import BOOTLOADER_BINS from .build_constants import JSON_METADATA @@ -10,21 +12,38 @@ from .file_utils import bin_file_contains from .file_utils import bin_files_differ from .file_utils import file_contains from .file_utils import replace_in_file -from .idf_utils import EnvDict from .idf_utils import EXT_IDF_PATH +from .idf_utils import EnvDict +from .idf_utils import IdfPyFunc from .idf_utils import find_python from .idf_utils import get_idf_build_env -from .idf_utils import IdfPyFunc from .idf_utils import run_cmake from .idf_utils import run_cmake_and_build from .idf_utils import run_idf_py -from .snapshot import get_snapshot from .snapshot import Snapshot +from .snapshot import get_snapshot __all__ = [ - 'append_to_file', 'replace_in_file', - 'get_idf_build_env', 'run_idf_py', 'EXT_IDF_PATH', 'EnvDict', 'IdfPyFunc', - 'Snapshot', 'get_snapshot', 'run_cmake', 'APP_BINS', 'BOOTLOADER_BINS', - 'PARTITION_BIN', 'JSON_METADATA', 'ALL_ARTIFACTS', - 'run_cmake_and_build', 'find_python', 'file_contains', 'bin_file_contains', 'bin_files_differ' + 'append_to_file', + 'replace_in_file', + 'get_idf_build_env', + 'run_idf_py', + 'EXT_IDF_PATH', + 'EnvDict', + 'IdfPyFunc', + 'Snapshot', + 'get_snapshot', + 'run_cmake', + 'APP_BINS', + 'BOOTLOADER_BINS', + 'PARTITION_BIN', + 'JSON_METADATA', + 'ALL_ARTIFACTS', + 'ALL_ARTIFACTS_BUILDV1', + 'ALL_ARTIFACTS_BUILDV2', + 'run_cmake_and_build', + 'find_python', + 'file_contains', + 'bin_file_contains', + 'bin_files_differ', ] diff --git a/tools/test_build_system/test_build_system_helpers/build_constants.py b/tools/test_build_system/test_build_system_helpers/build_constants.py index 90a6e56569..7ecf94f11b 100644 --- a/tools/test_build_system/test_build_system_helpers/build_constants.py +++ b/tools/test_build_system/test_build_system_helpers/build_constants.py @@ -1,12 +1,18 @@ -# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 BOOTLOADER_BINS = ['build/bootloader/bootloader.elf', 'build/bootloader/bootloader.bin'] APP_BINS = ['build/build_test_app.elf', 'build/build_test_app.bin'] PARTITION_BIN = ['build/partition_table/partition-table.bin'] -JSON_METADATA = ['build/project_description.json', 'build/flasher_args.json', 'build/config/kconfig_menus.json', 'build/config/sdkconfig.json'] -ALL_ARTIFACTS = [ - *BOOTLOADER_BINS, - *APP_BINS, - *PARTITION_BIN, - *JSON_METADATA -] +JSON_METADATA = ['build/project_description.json', 'build/flasher_args.json', 'build/config/sdkconfig.json'] + +# kconfig_menus.json is only generated during build in cmakev1. +KCONFIG_MENUS_JSON = ['build/config/kconfig_menus.json'] + +# Build system v1 artifacts +ALL_ARTIFACTS_BUILDV1 = [*BOOTLOADER_BINS, *APP_BINS, *PARTITION_BIN, *JSON_METADATA, *KCONFIG_MENUS_JSON] + +# Build system v2 artifacts +ALL_ARTIFACTS_BUILDV2 = [*BOOTLOADER_BINS, *APP_BINS, *PARTITION_BIN, *JSON_METADATA] + +# Default artifacts for tests that don't specify build version +ALL_ARTIFACTS = ALL_ARTIFACTS_BUILDV1 diff --git a/tools/test_build_system/test_rebuild.py b/tools/test_build_system/test_rebuild.py index 417fcb6511..430c0cc1b1 100644 --- a/tools/test_build_system/test_rebuild.py +++ b/tools/test_build_system/test_rebuild.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 # These tests check whether the build system rebuilds some files or not # depending on the changes to the project. @@ -7,7 +7,8 @@ import os from pathlib import Path import pytest -from test_build_system_helpers import ALL_ARTIFACTS +from test_build_system_helpers import ALL_ARTIFACTS_BUILDV1 +from test_build_system_helpers import ALL_ARTIFACTS_BUILDV2 from test_build_system_helpers import APP_BINS from test_build_system_helpers import BOOTLOADER_BINS from test_build_system_helpers import PARTITION_BIN @@ -17,7 +18,7 @@ from test_build_system_helpers import replace_in_file @pytest.mark.usefixtures('test_app_copy') -def test_rebuild_no_changes(idf_py: IdfPyFunc) -> None: +def test_rebuild_no_changes(idf_py: IdfPyFunc, request: pytest.FixtureRequest) -> None: logging.info('initial build') idf_py('build') logging.info('get the first snapshot') @@ -32,7 +33,8 @@ def test_rebuild_no_changes(idf_py: IdfPyFunc) -> None: ) logging.info('check that all build artifacts were generated') - for artifact in ALL_ARTIFACTS: + all_artifacts = ALL_ARTIFACTS_BUILDV2 if request.config.getoption('buildv2', False) else ALL_ARTIFACTS_BUILDV1 + for artifact in all_artifacts: assert Path(artifact).exists() logging.info('build again with no changes')