58 lines
1.2 KiB
Python
58 lines
1.2 KiB
Python
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).parent.parent
|
|
TESTS_DIR = Path(__file__).parent
|
|
RESULTS_JSON = TESTS_DIR / "results.json"
|
|
REPORT_HTML = TESTS_DIR / "charts" / "report.html"
|
|
CHARTS_DIR = TESTS_DIR / "charts"
|
|
|
|
|
|
def run_pytest() -> int:
|
|
CHARTS_DIR.mkdir(parents=True, exist_ok=True)
|
|
|
|
args = [
|
|
sys.executable, "-m", "pytest",
|
|
|
|
str(TESTS_DIR / "unit"),
|
|
str(TESTS_DIR / "integration"),
|
|
str(TESTS_DIR / "e2e"),
|
|
str(TESTS_DIR / "llm"),
|
|
|
|
"--json-report",
|
|
f"--json-report-file={RESULTS_JSON}",
|
|
|
|
f"--html={REPORT_HTML}",
|
|
"--self-contained-html",
|
|
|
|
f"--cov=api",
|
|
f"--cov=core",
|
|
"--cov-report=term-missing",
|
|
f"--cov-report=html:{CHARTS_DIR / 'coverage'}",
|
|
|
|
"-p", "no:terminal",
|
|
"--tb=short",
|
|
"-q",
|
|
]
|
|
|
|
return subprocess.run(args, cwd=str(ROOT), check=False).returncode
|
|
|
|
|
|
def run_charts():
|
|
from testing.reports.charts import generate
|
|
out = generate()
|
|
print(f"Charts saved: {out}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
print("Start testing")
|
|
|
|
code = run_pytest()
|
|
|
|
if RESULTS_JSON.exists():
|
|
run_charts()
|
|
|
|
print("Stop testing")
|
|
|
|
sys.exit(code) |