From 5f4a5a9705aadcec8fef33d079da6b95ecddd7b2 Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 22 Feb 2024 15:18:21 +0100 Subject: [PATCH] fix: wrongly terminate the version solver when versions not been found at the first round --- .../version_solver/version_solver.py | 6 ++-- integration_tests/test_targets.py | 4 +-- integration_tests/test_version_solver.py | 33 ++++++++++++++++++- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/idf_component_manager/version_solver/version_solver.py b/idf_component_manager/version_solver/version_solver.py index bb547429..72c20465 100644 --- a/idf_component_manager/version_solver/version_solver.py +++ b/idf_component_manager/version_solver/version_solver.py @@ -3,7 +3,7 @@ import os -from idf_component_tools.errors import DependencySolveError, SolverError +from idf_component_tools.errors import DependencySolveError, FetchingError, SolverError from idf_component_tools.manifest import ( ComponentRequirement, ComponentWithVersions, @@ -123,7 +123,9 @@ def get_versions_from_sources( latest_source = source if cmp_with_versions.versions: break - except ComponentNotFound: + # ComponentNotFound will be raised by API client + # FetchingError will be raised by sources + except (ComponentNotFound, FetchingError): pass return cmp_with_versions, latest_source diff --git a/integration_tests/test_targets.py b/integration_tests/test_targets.py index 4df6f346..19ec4206 100644 --- a/integration_tests/test_targets.py +++ b/integration_tests/test_targets.py @@ -81,8 +81,8 @@ def test_idf_check_target_fail_manifest(project): def test_idf_check_target_fail_dependency(project): res = set_target(project, 'esp32') assert ( - 'Cannot find versions of "example/cmp" satisfying "0.0.1" for the current target "esp32"' - in res + 'Because project depends on example/cmp (0.0.1) which doesn\'t match any versions, ' + 'version solving failed.' in res ) diff --git a/integration_tests/test_version_solver.py b/integration_tests/test_version_solver.py index 46ef9348..821bd457 100644 --- a/integration_tests/test_version_solver.py +++ b/integration_tests/test_version_solver.py @@ -1,4 +1,4 @@ -# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 import os import shutil @@ -474,3 +474,34 @@ def test_multiple_storage_urls(monkeypatch, project): assert 'Configuring done' in output assert 'example/cmp (3.3.3)' in output assert 'test/cmp2 (1.0.0) from file:///' in output + + +@pytest.mark.parametrize( + 'project', + [ + { + 'components': { + 'main': { + 'dependencies': { + 'usb_host_ch34x_vcp': {'version': '^2'}, + 'usb_host_cp210x_vcp': {'version': '^2'}, + 'usb_host_ftdi_vcp': {'version': '^2'}, + 'usb_host_vcp': {'version': '^1'}, + } + }, + }, + } + ], + indirect=True, +) +@pytest.mark.skipif( + (os.getenv('IDF_BRANCH', 'master') or 'master') != 'master', + reason='only test it in master branch', +) +def test_complex_version_solving(monkeypatch, project): + output = project_action(project, 'reconfigure') + assert 'version solving failed' in output + + shutil.rmtree(os.path.join(project, 'build')) + output = project_action(project, '--preview', 'set-target', 'esp32p4', 'reconfigure') + assert 'Configuring done' in output