File size: 2,795 Bytes
6a0ff33 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | """Integration test: C++ DAG engine compilation."""
import os
import subprocess
import sys
import pytest
@pytest.mark.skipif(
not any(
os.path.exists(p)
for p in [
r"C:\Program Files\CMake\bin\cmake.exe",
r"C:\Program Files (x86)\CMake\bin\cmake.exe",
"/usr/bin/cmake",
"/usr/local/bin/cmake",
]
)
and subprocess.run(["cmake", "--version"], capture_output=True).returncode != 0,
reason="CMake not found on system",
)
class TestCppBuild:
"""Test that the C++ DAG engine compiles successfully."""
@staticmethod
def _project_root():
return os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
def test_cmake_configure(self):
"""CMake should configure without errors."""
root = self._project_root()
build_dir = os.path.join(root, "cpp", "build")
os.makedirs(build_dir, exist_ok=True)
result = subprocess.run(
["cmake", "-S", os.path.join(root, "cpp"), "-B", build_dir],
capture_output=True,
text=True,
cwd=root,
)
assert result.returncode == 0, f"CMake configure failed:\n{result.stderr}"
def test_cmake_build(self):
"""CMake should build the autoforge-dag target."""
root = self._project_root()
build_dir = os.path.join(root, "cpp", "build")
# Ensure configured
subprocess.run(
["cmake", "-S", os.path.join(root, "cpp"), "-B", build_dir],
capture_output=True,
cwd=root,
)
result = subprocess.run(
["cmake", "--build", build_dir],
capture_output=True,
text=True,
cwd=root,
)
assert result.returncode == 0, f"CMake build failed:\n{result.stderr}"
def test_binary_exists(self):
"""The built binary should exist."""
root = self._project_root()
build_dir = os.path.join(root, "cpp", "build")
# Build if needed
subprocess.run(["cmake", "-S", os.path.join(root, "cpp"), "-B", build_dir], capture_output=True, cwd=root)
subprocess.run(["cmake", "--build", build_dir], capture_output=True, cwd=root)
# Check for binary (platform-dependent extension)
if sys.platform == "win32":
candidates = [
os.path.join(build_dir, "autoforge-dag.exe"),
os.path.join(build_dir, "Debug", "autoforge-dag.exe"),
os.path.join(build_dir, "Release", "autoforge-dag.exe"),
]
else:
candidates = [os.path.join(build_dir, "autoforge-dag")]
assert any(os.path.exists(c) for c in candidates), (
f"Binary not found. Checked: {candidates}"
)
|