From 5f239a862b61c50cd1147a69f85b81c8f5d67e83 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 | 4 +++- tools/test_idf_tools/test_idf_tools.py | 25 ++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.gitlab/ci/host-test.yml b/.gitlab/ci/host-test.yml index 10141c01ba..33d6174eb8 100644 --- a/.gitlab/ci/host-test.yml +++ b/.gitlab/ci/host-test.yml @@ -125,7 +125,9 @@ test_idf_tools: entrypoint: [""] # use system python3. no extra pip package installed script: # Tools must be downloaded for testing - - python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa + # We could use "idf_tools.py download all", but we don't want to install clang because of its huge size + # 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/tools/test_idf_tools/test_idf_tools.py b/tools/test_idf_tools/test_idf_tools.py index a719059d8f..6c113f52cd 100755 --- a/tools/test_idf_tools/test_idf_tools.py +++ b/tools/test_idf_tools/test_idf_tools.py @@ -502,10 +502,29 @@ class TestUsage(unittest.TestCase): def test_export_supported_version_cmake(self): tool_to_test = 'cmake' - self.run_idf_tools_with_action(['install']) - output = self.run_idf_tools_with_action(['export']) + 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.assertNotIn(tool_to_test, output) + 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) class TestMaintainer(unittest.TestCase):