|
9 | 9 |
|
10 | 10 | from typer.testing import CliRunner |
11 | 11 |
|
12 | | -from cppython.console.entry import app |
13 | | - |
14 | 12 | pytest_plugins = ['tests.fixtures.example'] |
15 | 13 |
|
16 | 14 |
|
17 | 15 | class TestConanCMake: |
18 | 16 | """Test project variation of conan and CMake""" |
19 | 17 |
|
20 | 18 | @staticmethod |
21 | | - def test_simple(example_runner: CliRunner) -> None: |
| 19 | + def test_simple(example_runner: CliRunner, fresh_environment: dict[str, str]) -> None: |
22 | 20 | """Simple project""" |
23 | | - result = example_runner.invoke( |
24 | | - app, |
25 | | - [ |
26 | | - 'install', |
27 | | - ], |
28 | | - ) |
| 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, env=fresh_environment, check=False) |
29 | 23 |
|
30 | | - assert result.exit_code == 0, result.output |
| 24 | + assert result.returncode == 0, f'PDM install failed: {result.stderr}' |
31 | 25 |
|
32 | 26 | # Run the CMake configuration command |
33 | | - cmake_result = subprocess.run(['cmake', '--preset=default'], capture_output=True, text=True, check=False) |
| 27 | + result = subprocess.run( |
| 28 | + ['cmake', '--preset=default'], capture_output=True, text=True, env=fresh_environment, check=False |
| 29 | + ) |
34 | 30 |
|
35 | | - assert cmake_result.returncode == 0, f'CMake configuration failed: {cmake_result.stderr}' |
| 31 | + assert result.returncode == 0, f'Cmake failed: {result.stderr}' |
36 | 32 |
|
37 | 33 | # Verify that the build directory contains the expected files |
38 | 34 | assert (Path('build') / 'CMakeCache.txt').exists(), 'build/CMakeCache.txt not found' |
39 | 35 |
|
40 | 36 | @staticmethod |
41 | | - def test_inject(example_runner: CliRunner) -> None: |
| 37 | + def test_inject(example_runner: CliRunner, fresh_environment: dict[str, str]) -> None: |
42 | 38 | """Inject""" |
43 | | - result = example_runner.invoke( |
44 | | - app, |
45 | | - [ |
46 | | - 'install', |
47 | | - ], |
48 | | - ) |
| 39 | + # By nature of running the test, we require PDM to develop the project and so it will be installed |
| 40 | + result = subprocess.run(['pdm', 'install'], capture_output=True, text=True, env=fresh_environment, check=False) |
49 | 41 |
|
50 | | - assert result.exit_code == 0, result.output |
| 42 | + assert result.returncode == 0, f'PDM install failed: {result.stderr}' |
51 | 43 |
|
52 | 44 | # Run the CMake configuration command |
53 | | - cmake_result = subprocess.run(['cmake', '--preset=default'], capture_output=True, text=True, check=False) |
| 45 | + result = subprocess.run( |
| 46 | + ['cmake', '--preset=default'], capture_output=True, text=True, env=fresh_environment, check=False |
| 47 | + ) |
54 | 48 |
|
55 | | - assert cmake_result.returncode == 0, f'CMake configuration failed: {cmake_result.stderr}' |
| 49 | + assert result.returncode == 0, f'Cmake failed: {result.stderr}' |
56 | 50 |
|
57 | 51 | # Verify that the build directory contains the expected files |
58 | 52 | assert (Path('build') / 'CMakeCache.txt').exists(), 'build/CMakeCache.txt not found' |
0 commit comments