-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
48 lines (34 loc) · 1.12 KB
/
Copy pathrun_tests.py
File metadata and controls
48 lines (34 loc) · 1.12 KB
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
#!/usr/bin/env python3
"""
Test runner for the OSL repository.
Default:
python run_tests.py
With coverage:
python run_tests.py --coverage
Stress tests (not run by default):
python run_tests.py --stress
"""
from __future__ import annotations
import argparse
import os
import subprocess
import sys
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parent
def main() -> int:
parser = argparse.ArgumentParser(description="Run the OSL test suite.")
parser.add_argument("--coverage", action="store_true", help="Enable coverage reporting (pytest-cov).")
parser.add_argument("--stress", action="store_true", help="Run stress tests (marked 'stress').")
args = parser.parse_args()
env = os.environ.copy()
env.setdefault("MPLBACKEND", "Agg")
cmd = [sys.executable, "-m", "pytest", "-q"]
if args.coverage:
cmd += ["--cov=osl", "--cov-report=term-missing", "--cov-branch"]
if args.stress:
cmd += ["-m", "stress"]
else:
cmd += ["-m", "not stress"]
return subprocess.call(cmd, cwd=REPO_ROOT, env=env)
if __name__ == "__main__":
raise SystemExit(main())