From 335ba6b3c2dcd0aee6719a59b084b53414e25cb3 Mon Sep 17 00:00:00 2001 From: Marek Fiala Date: Mon, 2 Jun 2025 15:08:44 +0200 Subject: [PATCH] test(tools): Added test for installing supported tool version Added test_export_supported_version_cmake in `test_idf_tools.py`, that installs and exports supported version of tool - cmake. --- .gitlab/ci/host-test.yml | 3 ++- .gitlab/ci/test-win.yml | 3 ++- tools/test_idf_tools/test_idf_tools.py | 26 ++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index c910ad5042..29ad28d582 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -113,7 +113,8 @@ test_cli_installer: script: # Tools must be downloaded for testing # We could use "idf_tools.py download all", but we don't want to install clang because of its huge size - - python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa cmake + # cmake@version that is supported + - python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa cmake cmake@3.16.3 - cd ${IDF_PATH}/tools/test_idf_tools - python3 -m pip install jsonschema - python3 ./test_idf_tools.py -v diff --git a/.gitlab/ci/test-win.yml b/.gitlab/ci/test-win.yml index 02177c4405..780d3f98fb 100644 --- a/.gitlab/ci/test-win.yml +++ b/.gitlab/ci/test-win.yml @@ -35,7 +35,8 @@ test_cli_installer_win: timeout: 3h script: # Tools must be downloaded for testing - - python ${IDF_PATH}\tools\idf_tools.py download required qemu-riscv32 qemu-xtensa cmake + # cmake@version that is supported + - python ${IDF_PATH}\tools\idf_tools.py download required qemu-riscv32 qemu-xtensa cmake cmake@3.16.3 - cd ${IDF_PATH}\tools\test_idf_tools - python -m pip install jsonschema - python .\test_idf_tools.py diff --git a/tools/test_idf_tools/test_idf_tools.py b/tools/test_idf_tools/test_idf_tools.py index 4441df304f..2df939cf6a 100755 --- a/tools/test_idf_tools/test_idf_tools.py +++ b/tools/test_idf_tools/test_idf_tools.py @@ -313,6 +313,32 @@ class TestUsage(TestUsageBase): self.assertIn(os.path.join(tool_to_test, tool_version), output) + def test_export_supported_version_cmake(self): + tool_to_test = 'cmake' + supported_version = '' + recommended_version = '' + for tool in self.tools_dict['tools']: + if tool['name'] != tool_to_test: + continue + for version in tool['versions']: + if version['status'] == 'supported': + supported_version = version['name'] + elif version['status'] == 'recommended': + recommended_version = version['name'] + + self.run_idf_tools_with_action(['install']) + output = self.run_idf_tools_with_action(['install', f'{tool_to_test}@{supported_version}']) + self.assert_tool_installed(output, tool_to_test, supported_version) + + # Remove the recommended version folder installed by install command (in case of Windows) + recommended_version_folder = os.path.join(self.temp_tools_dir, 'tools', tool_to_test, recommended_version) + if os.path.exists(recommended_version_folder): + shutil.rmtree(recommended_version_folder) + + output = self.run_idf_tools_with_action(['export']) + self.assertIn(os.path.join(tool_to_test, supported_version), output) + self.assertNotIn(os.path.join(tool_to_test, recommended_version), output) + def test_export_prefer_system_cmake(self): tool_to_test = 'cmake' self.run_idf_tools_with_action(['install'])