File size: 738 Bytes
9897e20 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import subprocess
import pytest
import os
@pytest.fixture(scope="session", autouse=True)
def run_ctest():
build_dir = "build" # Replace this with the path to your build directory
print("Running ctest in", os.path.abspath(build_dir))
# Run ctest in the build directory
try:
result = subprocess.run(["ctest"], check=True, cwd=build_dir, capture_output=True, text=True)
print("ctest stdout:")
print(result.stdout)
print("ctest stderr:")
print(result.stderr)
except subprocess.CalledProcessError as e:
print(f"ctest failed with error code {e.returncode}")
print("Error output:")
print(e.output)
raise # Re-raise the exception to make pytest fail
|