|
| 1 | +"""TODO""" |
| 2 | + |
| 3 | +import subprocess |
| 4 | + |
| 5 | +from typer.testing import CliRunner |
| 6 | + |
| 7 | +from cppython.console.entry import app |
| 8 | + |
| 9 | +pytest_plugins = ['tests.fixtures.example'] |
| 10 | + |
| 11 | + |
| 12 | +class TestVcpkgCMake: |
| 13 | + """Test project variation of vcpkg and CMake""" |
| 14 | + |
| 15 | + @staticmethod |
| 16 | + def test_simple(example_runner: CliRunner) -> None: |
| 17 | + """Simple project""" |
| 18 | + result = example_runner.invoke( |
| 19 | + app, |
| 20 | + [ |
| 21 | + 'install', |
| 22 | + ], |
| 23 | + ) |
| 24 | + |
| 25 | + assert result.exit_code == 0, result.output |
| 26 | + |
| 27 | + # Run the CMake configuration command |
| 28 | + cmake_result = subprocess.run(['cmake', '--preset=default'], capture_output=True, text=True, check=False) |
| 29 | + |
| 30 | + assert cmake_result.returncode == 0, f'CMake configuration failed: {cmake_result.stderr}' |
| 31 | + |
| 32 | + # Run the CMake build command |
| 33 | + build_result = subprocess.run(['cmake', '--build', 'build'], capture_output=True, text=True, check=False) |
| 34 | + |
| 35 | + assert build_result.returncode == 0, f'CMake build failed: {build_result.stderr}' |
| 36 | + assert 'Build finished successfully' in build_result.stdout, 'CMake build did not finish successfully' |
| 37 | + |
| 38 | + # Execute the built program and verify the output |
| 39 | + program_result = subprocess.run(['build/HelloWorld'], capture_output=True, text=True, check=False) |
| 40 | + |
| 41 | + assert program_result.returncode == 0, f'Program execution failed: {program_result.stderr}' |
| 42 | + |
| 43 | + assert 'Hello, World!' in program_result.stdout, 'Program output did not match expected output' |
0 commit comments