"""Build all targets and run the example and solution tests."""

import os
import subprocess
from pathlib import Path

root = Path(__file__).resolve().parent
environment = dict(os.environ)
environment.setdefault("QT_QPA_PLATFORM", "offscreen")
for command in [
    ["cmake", "-S", ".", "-B", "build", "-DCMAKE_BUILD_TYPE=Debug"],
    ["cmake", "--build", "build", "--parallel", "2"],
    ["ctest", "--test-dir", "build", "--output-on-failure"],
]:
    subprocess.run(command, cwd=root, env=environment, check=True, timeout=600)
