Skip to content

Commit 158de72

Browse files
committed
Merge branch 'development' of https://github.com/Behemyth/CPPython into development
2 parents 582116c + 5b1aee6 commit 158de72

File tree

3 files changed

+5
-129
lines changed

3 files changed

+5
-129
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@
1414
"source.organizeImports": "explicit"
1515
},
1616
"editor.defaultFormatter": "charliermarsh.ruff"
17-
}
17+
},
18+
"cmake.ignoreCMakeListsMissing": true
1819
}

cppython/plugins/conan/plugin.py

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,40 +57,7 @@ def information() -> Information:
5757
"""
5858
return Information()
5959

60-
def _install_dependencies(self, *, update: bool = False) -> None:
61-
"""Install/update dependencies using Conan API.
62-
63-
Args:
64-
update: If True, check remotes for newer versions/revisions and install those.
65-
If False, use cached versions when available.
66-
"""
67-
operation = 'update' if update else 'install'
68-
69-
try:
70-
# Setup environment and generate conanfile
71-
conan_api, conanfile_path = self._prepare_installation()
72-
except Exception as e:
73-
raise ProviderInstallationError('conan', f'Failed to prepare {operation} environment: {e}', e) from e
74-
75-
try:
76-
# Load dependency graph
77-
deps_graph = self._load_dependency_graph(conan_api, conanfile_path, update)
78-
except Exception as e:
79-
raise ProviderInstallationError('conan', f'Failed to load dependency graph: {e}', e) from e
80-
81-
try:
82-
# Install dependencies
83-
self._install_binaries(conan_api, deps_graph, update)
84-
except Exception as e:
85-
raise ProviderInstallationError('conan', f'Failed to install binary dependencies: {e}', e) from e
86-
87-
try:
88-
# Generate consumer files
89-
self._generate_consumer_files(conan_api, deps_graph)
90-
except Exception as e:
91-
raise ProviderInstallationError('conan', f'Failed to generate consumer files: {e}', e) from e
92-
93-
def _prepare_installation(self) -> tuple[ConanAPI, Path]:
60+
def _setup_environment(self) -> tuple[ConanAPI, Path]:
9461
"""Prepare the installation environment and generate conanfile.
9562
9663
Returns:
@@ -186,11 +153,11 @@ def _generate_consumer_files(self, conan_api: ConanAPI, deps_graph) -> None:
186153

187154
def install(self) -> None:
188155
"""Installs the provider"""
189-
self._install_dependencies(update=False)
156+
self._setup_environment()
190157

191158
def update(self) -> None:
192159
"""Updates the provider"""
193-
self._install_dependencies(update=True)
160+
self._setup_environment()
194161

195162
@staticmethod
196163
def supported_sync_type(sync_type: type[SyncData]) -> bool:

tests/unit/plugins/conan/test_install.py

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,9 @@
66

77
import pytest
88
from packaging.requirements import Requirement
9-
from pytest_mock import MockerFixture
109

1110
from cppython.plugins.conan.plugin import ConanProvider
12-
from cppython.plugins.conan.schema import ConanDependency
1311
from cppython.test.pytest.mixins import ProviderPluginTestMixin
14-
from cppython.utility.exception import ProviderInstallationError
1512

1613
# Constants for test assertions
1714
EXPECTED_PROFILE_CALLS = 2
@@ -81,92 +78,3 @@ def test_with_dependencies(
8178

8279
# Verify build path was created
8380
assert plugin.core_data.cppython_data.build_path.exists()
84-
85-
# Verify ConanAPI constructor was called
86-
conan_setup_mocks['conan_api_constructor'].assert_called_once()
87-
88-
def test_conan_command_failure(
89-
self,
90-
plugin: ConanProvider,
91-
conan_temp_conanfile: Path,
92-
conan_mock_dependencies: list[Requirement],
93-
conan_mock_api: Mock,
94-
mocker: MockerFixture,
95-
) -> None:
96-
"""Test install method when conan API operations fail
97-
98-
Args:
99-
plugin: The plugin instance
100-
conan_temp_conanfile: Path to temporary conanfile.py
101-
conan_mock_dependencies: List of mock dependencies
102-
conan_mock_api: Mock ConanAPI instance
103-
mocker: Pytest mocker fixture
104-
"""
105-
# Mock builder
106-
mock_builder = mocker.Mock()
107-
mock_builder.generate_conanfile = mocker.Mock()
108-
plugin.builder = mock_builder # type: ignore[attr-defined]
109-
110-
# Configure the API mock to fail on graph loading
111-
conan_mock_api.graph.load_graph_consumer.side_effect = Exception('Conan API error: package not found')
112-
113-
# Mock ConanAPI constructor to return our configured mock
114-
mock_conan_api_constructor = mocker.patch('cppython.plugins.conan.plugin.ConanAPI', return_value=conan_mock_api)
115-
116-
# Mock resolve_conan_dependency
117-
def mock_resolve(requirement: Requirement) -> ConanDependency:
118-
return ConanDependency(name=requirement.name)
119-
120-
mocker.patch('cppython.plugins.conan.plugin.resolve_conan_dependency', side_effect=mock_resolve)
121-
122-
# Add a dependency
123-
plugin.core_data.cppython_data.dependencies = [conan_mock_dependencies[0]]
124-
125-
# Execute and verify exception is raised
126-
with pytest.raises(
127-
ProviderInstallationError,
128-
match='Failed to load dependency graph: Conan API error: package not found',
129-
):
130-
plugin.install()
131-
132-
# Verify builder was still called
133-
mock_builder.generate_conanfile.assert_called_once()
134-
135-
# Verify Conan API was attempted
136-
mock_conan_api_constructor.assert_called_once()
137-
138-
def test_with_default_profiles(
139-
self,
140-
plugin: ConanProvider,
141-
conan_temp_conanfile: Path,
142-
conan_mock_dependencies: list[Requirement],
143-
conan_setup_mocks: dict[str, Mock],
144-
conan_mock_api: Mock,
145-
) -> None:
146-
"""Test install method uses pre-resolved profiles from plugin construction
147-
148-
Args:
149-
plugin: The plugin instance
150-
conan_temp_conanfile: Path to temporary conanfile.py
151-
conan_mock_dependencies: List of mock dependencies
152-
conan_setup_mocks: Dictionary containing all mocks
153-
conan_mock_api: Mock ConanAPI instance
154-
"""
155-
# Setup dependencies
156-
plugin.core_data.cppython_data.dependencies = conan_mock_dependencies
157-
158-
# Execute - should use the profiles resolved during plugin construction
159-
plugin.install()
160-
161-
# Verify that the API was used for installation
162-
conan_setup_mocks['conan_api_constructor'].assert_called_once()
163-
164-
# Verify the rest of the process continued with resolved profiles
165-
conan_mock_api.graph.load_graph_consumer.assert_called_once()
166-
conan_mock_api.install.install_binaries.assert_called_once()
167-
conan_mock_api.install.install_consumer.assert_called_once()
168-
169-
# Verify that the resolved profiles were used in the graph loading
170-
call_args = conan_mock_api.graph.load_graph_consumer.call_args
171-
assert call_args.kwargs['profile_host'] == plugin.data.host_profile
172-
assert call_args.kwargs['profile_build'] == plugin.data.build_profile

0 commit comments

Comments
 (0)