Skip to content

Commit b8cacb2

Browse files
committed
Update vcpkg Example Installation
1 parent 316f337 commit b8cacb2

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

tests/fixtures/vcpkg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Shared fixtures for VCPkg plugin tests"""

tests/integration/examples/test_vcpkg_cmake.py

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,54 @@
66

77
import subprocess
88
from pathlib import Path
9+
from tomllib import loads
910

1011
from typer.testing import CliRunner
1112

12-
pytest_plugins = ['tests.fixtures.example']
13+
from cppython.console.schema import ConsoleInterface
14+
from cppython.core.schema import ProjectConfiguration
15+
from cppython.project import Project
16+
17+
pytest_plugins = ['tests.fixtures.example', 'tests.fixtures.vcpkg']
1318

1419

1520
class TestVcpkgCMake:
1621
"""Test project variation of vcpkg and CMake"""
1722

23+
@staticmethod
24+
def _create_project(skip_upload: bool = True) -> Project:
25+
"""Create a project instance with common configuration."""
26+
project_root = Path.cwd()
27+
config = ProjectConfiguration(project_root=project_root, version=None, verbosity=2, debug=True)
28+
interface = ConsoleInterface()
29+
30+
pyproject_path = project_root / 'pyproject.toml'
31+
pyproject_data = loads(pyproject_path.read_text(encoding='utf-8'))
32+
33+
if skip_upload:
34+
TestVcpkgCMake._ensure_vcpkg_config(pyproject_data)
35+
pyproject_data['tool']['cppython']['providers']['vcpkg']['skip_upload'] = True
36+
37+
return Project(config, interface, pyproject_data)
38+
39+
@staticmethod
40+
def _ensure_vcpkg_config(pyproject_data: dict) -> None:
41+
"""Helper method to ensure Vcpkg configuration exists in pyproject data"""
42+
if 'tool' not in pyproject_data:
43+
pyproject_data['tool'] = {}
44+
if 'cppython' not in pyproject_data['tool']:
45+
pyproject_data['tool']['cppython'] = {}
46+
if 'providers' not in pyproject_data['tool']['cppython']:
47+
pyproject_data['tool']['cppython']['providers'] = {}
48+
if 'vcpkg' not in pyproject_data['tool']['cppython']['providers']:
49+
pyproject_data['tool']['cppython']['providers']['vcpkg'] = {}
50+
1851
@staticmethod
1952
def test_simple(example_runner: CliRunner) -> None:
2053
"""Simple project"""
21-
# By nature of running the test, we require PDM to develop the project and so it will be installed
22-
result = subprocess.run(['pdm', 'install'], capture_output=True, text=True, check=False)
23-
24-
assert result.returncode == 0, f'PDM install failed: {result.stderr}'
54+
# Create project and install dependencies
55+
project = TestVcpkgCMake._create_project(skip_upload=False)
56+
project.install()
2557

2658
# Run the CMake configuration command
2759
result = subprocess.run(['cmake', '--preset=default'], capture_output=True, text=True, check=False)

0 commit comments

Comments
 (0)