Skip to content

Commit 45598d1

Browse files
committed
Copy User Profile
1 parent a9f9571 commit 45598d1

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

tests/fixtures/conan.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Shared fixtures for Conan plugin tests"""
22

3+
import os
34
from pathlib import Path
45
from typing import Any
56
from unittest.mock import Mock
@@ -34,7 +35,8 @@ def fixture_conan_plugin_data(request) -> dict[str, Any]:
3435
def clean_conan_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
3536
"""Sets CONAN_HOME to a temporary directory for each test.
3637
37-
This ensures all tests run with a clean Conan cache.
38+
This ensures all tests run with a clean Conan cache. Copies the user's
39+
default profile if it exists to ensure tests have valid compiler settings.
3840
3941
Args:
4042
tmp_path: Pytest temporary directory fixture
@@ -43,6 +45,17 @@ def clean_conan_cache(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
4345
conan_home = tmp_path / 'conan_home'
4446
conan_home.mkdir()
4547

48+
# Copy user's default profile if it exists
49+
user_conan_home = Path(os.getenv('CONAN_USER_HOME', Path.home() / '.conan2'))
50+
user_profiles = user_conan_home / 'profiles'
51+
if user_profiles.exists():
52+
test_profiles = conan_home / 'profiles'
53+
test_profiles.mkdir(parents=True, exist_ok=True)
54+
55+
for profile_file in ('default', 'default_build'):
56+
if (src := user_profiles / profile_file).exists():
57+
src.copy(test_profiles / profile_file)
58+
4659
# Set CONAN_HOME to the temporary directory
4760
monkeypatch.setenv('CONAN_HOME', str(conan_home))
4861

0 commit comments

Comments
 (0)