From e56672a42a933263c414800847cb6e5a5048e9bc Mon Sep 17 00:00:00 2001 From: Marek Fiala Date: Thu, 4 Jun 2026 15:20:13 +0200 Subject: [PATCH] test(tools): Added minimal supported cmake versions build system tests Backport of efa75a9b6056b4f0d7d5d18b93abd01d5e6d883c to release/v5.5. Adapted from the master version because of structural differences on release/v5.5: - The new jobs are added to .gitlab/ci/host-test.yml (where build-system pytest jobs live on v5.5) instead of .gitlab/ci/build.yml. - The minimum supported cmake version is 3.16.3 on v5.5 (cmake_minimum_required(VERSION 3.16) in tools/cmake/project.cmake), so the new jobs test cmake@3.16.3 instead of 3.22.1. - The macOS template extraction from the original commit is omitted: v5.5 already uses .brew-macos-settings for the macOS variables, so the refactor would be redundant. Co-authored-by: Cursor --- .gitlab/ci/host-test.yml | 34 ++++++++++++++++++++++++++++++ .gitlab/ci/test-win.yml | 34 ++++++++++++++++++++++++++++++ tools/test_idf_py/pytest.ini | 2 +- tools/test_idf_py/test_idf_qemu.py | 18 +++++++++------- 4 files changed, 79 insertions(+), 9 deletions(-) diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index 9d3ce899324..3baf3247a1e 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -461,6 +461,29 @@ test_pytest_macos: --junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml --ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME} +.test_build_system_minimal_cmake_template: + extends: .test_build_system_template + variables: + INSTALL_EXTRA_TOOLS: cmake@3.16.3 + script: + - MINIMAL_SUPPORTED_CMAKE_VERSION=$(echo "${INSTALL_EXTRA_TOOLS}" | sed -n 's/.*cmake@\([0-9.]*\).*/\1/p') + - export PATH=$(echo "$PATH" | sed -E "s|/tools/cmake/[0-9.]+|/tools/cmake/${MINIMAL_SUPPORTED_CMAKE_VERSION}|") + - ACTUAL_CMAKE_VERSION=$(cmake --version | head -n1 | awk '{print $3}') + - | + if [ "${ACTUAL_CMAKE_VERSION}" != "${MINIMAL_SUPPORTED_CMAKE_VERSION}" ]; then + echo "ERROR: Wrong minimal CMake version! Detected: ${ACTUAL_CMAKE_VERSION}, but should be: ${MINIMAL_SUPPORTED_CMAKE_VERSION}" + exit 1 + fi + - ${IDF_PATH}/tools/ci/test_configure_ci_environment.sh + - cd ${IDF_PATH}/tools/test_build_system + - run_cmd idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME} + - pytest + -k cmake + --cleanup-idf-copy + --work-dir ${CI_PROJECT_DIR}/test_build_system + --junitxml ${CI_PROJECT_DIR}/XUNIT_RESULT.xml + --ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME} + pytest_build_system: extends: .test_build_system_template parallel: 3 @@ -471,3 +494,14 @@ pytest_build_system_macos: - .brew-macos-settings - .rules:build:macos parallel: 3 + +pytest_build_system_minimal_cmake: + extends: .test_build_system_minimal_cmake_template + +pytest_build_system_macos_minimal_cmake: + extends: + - .test_build_system_minimal_cmake_template + - .brew-macos-settings + - .rules:build:macos + variables: + INSTALL_EXTRA_TOOLS: ninja cmake@3.16.3 diff --git a/.gitlab/ci/test-win.yml b/.gitlab/ci/test-win.yml index aa14be7ba76..65185645c0e 100644 --- a/.gitlab/ci/test-win.yml +++ b/.gitlab/ci/test-win.yml @@ -106,3 +106,37 @@ pytest_build_system_win: reports: junit: XUNIT_RESULT.xml when: always + +pytest_build_system_win_minimal_cmake: + extends: + - .test_build_system_template_win + - .rules:labels:windows_pytest_build_system + needs: + - job: manual_gate + optional: true + tags: [windows-build, brew] + artifacts: + paths: + - XUNIT_RESULT.xml + - test_build_system + expire_in: 2 days + reports: + junit: XUNIT_RESULT.xml + when: always + variables: + MINIMAL_CMAKE_VERSION: "3.16.3" + script: + - .\install.ps1 --enable-ci + - . .\export.ps1 + - python ${IDF_PATH}\tools\idf_tools.py install cmake@${MINIMAL_CMAKE_VERSION} + - $Env:PATH = "$Env:USERPROFILE\.espressif\tools\cmake\${MINIMAL_CMAKE_VERSION}\bin;$Env:PATH" + - | + $actualVersion = (& cmake --version).Split()[2] + if ($actualVersion -ne $Env:MINIMAL_CMAKE_VERSION) { + Write-Error "ERROR: Wrong CMake version! Detected: $actualVersion, but expected: $Env:MINIMAL_CMAKE_VERSION" + exit 1 + } + - python "${SUBMODULE_FETCH_TOOL}" -s "all" + - cd ${IDF_PATH}\tools\test_build_system + - idf-ci gitlab download-known-failure-cases-file ${KNOWN_FAILURE_CASES_FILE_NAME} + - pytest -k cmake --junitxml=${CI_PROJECT_DIR}\XUNIT_RESULT.xml --ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME} diff --git a/tools/test_idf_py/pytest.ini b/tools/test_idf_py/pytest.ini index 8cb59810c32..1ef576adc85 100644 --- a/tools/test_idf_py/pytest.ini +++ b/tools/test_idf_py/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = -s -p no:pytest_embedded -p no:idf-ci +addopts = -s -p no:idf-ci # log related log_cli = True diff --git a/tools/test_idf_py/test_idf_qemu.py b/tools/test_idf_py/test_idf_qemu.py index de277753c2b..8fe00fb3e53 100755 --- a/tools/test_idf_py/test_idf_qemu.py +++ b/tools/test_idf_py/test_idf_qemu.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2023-2026 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 import logging import os @@ -8,7 +8,12 @@ import sys import tempfile import unittest -import pexpect +if sys.platform == 'win32': + import pytest + + pytest.skip('pexpect.spawn is not available on Windows', allow_module_level=True) +else: + import pexpect class IdfPyQemuTest(unittest.TestCase): @@ -17,11 +22,9 @@ class IdfPyQemuTest(unittest.TestCase): idf_path = os.environ['IDF_PATH'] hello_world_dir = os.path.join(idf_path, 'examples', 'get-started', 'hello_world') idf_py = os.path.join(idf_path, 'tools', 'idf.py') - args = [idf_py, '-C', hello_world_dir, '-B', build_dir, - 'qemu', '--qemu-extra-args', '-no-reboot', 'monitor'] + args = [idf_py, '-C', hello_world_dir, '-B', build_dir, 'qemu', '--qemu-extra-args', '-no-reboot', 'monitor'] logfile_name = os.path.join(os.environ['IDF_PATH'], 'qemu_log.out') - with open(logfile_name, 'w+b') as logfile, \ - pexpect.spawn(sys.executable, args=args, logfile=logfile) as child: + with open(logfile_name, 'w+b') as logfile, pexpect.spawn(sys.executable, args=args, logfile=logfile) as child: child.expect_exact('Executing action: all') logging.info('Waiting for the build to finish...') child.expect_exact('Executing action: qemu', timeout=120) @@ -33,8 +36,7 @@ class IdfPyQemuTest(unittest.TestCase): child.expect_exact('Restarting now.') args = [idf_py, '-C', hello_world_dir, '-B', build_dir, 'qemu', 'efuse-summary', '--format=summary'] - with open(logfile_name, 'w+b') as logfile, \ - pexpect.spawn(sys.executable, args=args, logfile=logfile) as child: + with open(logfile_name, 'w+b') as logfile, pexpect.spawn(sys.executable, args=args, logfile=logfile) as child: child.expect_exact('Executing action: efuse-summary') child.expect_exact('WR_DIS (BLOCK0)')