Skip to content

Commit f9b4a25

Browse files
committed
Update Profile Again
1 parent 210a422 commit f9b4a25

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

cppython/plugins/conan/resolution.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ def _profile_post_process(profiles: list[Profile], conan_api: ConanAPI, cache_se
2929
"""
3030
logger = logging.getLogger('cppython.conan')
3131

32+
# Get global configuration
33+
global_conf = conan_api.config.global_conf
34+
3235
# Apply profile plugin processing
3336
try:
3437
profile_plugin = conan_api.profiles._load_profile_plugin()
@@ -41,13 +44,27 @@ def _profile_post_process(profiles: list[Profile], conan_api: ConanAPI, cache_se
4144
except (AttributeError, Exception):
4245
logger.debug('Profile plugin not available or failed to load')
4346

44-
# Process settings to initialize processed_settings
47+
# Apply the full profile processing pipeline for each profile
4548
for profile in profiles:
49+
# Process settings to initialize processed_settings
4650
try:
4751
profile.process_settings(cache_settings)
4852
except (AttributeError, Exception) as settings_error:
4953
logger.debug('Settings processing failed for profile: %s', str(settings_error))
5054

55+
# Validate configuration
56+
try:
57+
profile.conf.validate()
58+
except (AttributeError, Exception) as conf_error:
59+
logger.debug('Configuration validation failed for profile: %s', str(conf_error))
60+
61+
# Apply global configuration to the profile
62+
try:
63+
if global_conf is not None:
64+
profile.conf.rebase_conf_definition(global_conf)
65+
except (AttributeError, Exception) as rebase_error:
66+
logger.debug('Configuration rebase failed for profile: %s', str(rebase_error))
67+
5168

5269
def _resolve_profiles(
5370
host_profile_name: str | None, build_profile_name: str | None, conan_api: ConanAPI

tests/unit/plugins/conan/test_resolution.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,3 +444,36 @@ def test_resolve_conan_data_null_profiles(self, mock_resolve_profiles: Mock, moc
444444

445445
# Verify profile resolution was called with None values
446446
mock_resolve_profiles.assert_called_once_with(None, None, mock_conan_api)
447+
448+
def test_auto_detected_profile_gets_post_processed(self, conan_mock_api: Mock):
449+
"""Test that auto-detected profiles get proper post-processing.
450+
451+
Args:
452+
conan_mock_api: Mock ConanAPI instance from fixture
453+
"""
454+
# Configure the mock to simulate no default profiles
455+
conan_mock_api.profiles.get_default_host.side_effect = Exception('No default profile')
456+
conan_mock_api.profiles.get_default_build.side_effect = Exception('No default profile')
457+
458+
# Create a profile that simulates auto-detection
459+
mock_profile = Mock()
460+
mock_profile.settings = {'os': 'Windows', 'arch': 'x86_64'}
461+
mock_profile.process_settings = Mock()
462+
mock_profile.conf = Mock()
463+
mock_profile.conf.validate = Mock()
464+
mock_profile.conf.rebase_conf_definition = Mock()
465+
466+
conan_mock_api.profiles.detect.return_value = mock_profile
467+
conan_mock_api.config.global_conf = Mock()
468+
469+
# Call the resolution - this should trigger auto-detection and post-processing
470+
host_profile, build_profile = _resolve_profiles(None, None, conan_mock_api)
471+
472+
# Verify that process_settings was called on both profiles
473+
assert mock_profile.process_settings.call_count == EXPECTED_PROFILE_CALL_COUNT
474+
475+
# Verify that conf validation was called on both profiles
476+
assert mock_profile.conf.validate.call_count == EXPECTED_PROFILE_CALL_COUNT
477+
478+
# Verify that conf rebase was called on both profiles
479+
assert mock_profile.conf.rebase_conf_definition.call_count == EXPECTED_PROFILE_CALL_COUNT

0 commit comments

Comments
 (0)