import subprocess
from pathlib import Path


BASE_DIR = Path(__file__).resolve().parent.parent


def run_foundry_tests(verbose: bool = True) -> dict:
    cmd = ["forge", "test"]
    if verbose:
        cmd.append("-vv")

    result = subprocess.run(
        cmd,
        capture_output=True,
        text=True,
        cwd=str(BASE_DIR),  
    )

    return {
        "success": result.returncode == 0,
        "stdout": result.stdout,
        "stderr": result.stderr,
    }