-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrun-tests
More file actions
executable file
·55 lines (42 loc) · 1.26 KB
/
run-tests
File metadata and controls
executable file
·55 lines (42 loc) · 1.26 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
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""Run the test suite for all workspace packages."""
import subprocess
import sys
from pathlib import Path
try:
import tomllib
except ImportError:
import tomli as tomllib
def main() -> int:
root = Path(__file__).resolve().parent
with open(root / "pyproject.toml", "rb") as f:
config = tomllib.load(f)
packages = config["tool"]["uv"]["workspace"]["members"]
extra_args = sys.argv[1:]
failed = []
for pkg in packages:
pkg_dir = root / pkg
if not (pkg_dir / "tests").is_dir():
continue
print(f"=== {pkg} ===", flush=True)
result = subprocess.run(
["pytest", *extra_args],
cwd=pkg_dir,
)
if result.returncode != 0:
failed.append(pkg)
print(flush=True)
root_tests = root / "tests"
if root_tests.is_dir():
print("=== docs-sync ===", flush=True)
result = subprocess.run(["pytest", "tests", *extra_args], cwd=root)
if result.returncode != 0:
failed.append("docs-sync")
print(flush=True)
if failed:
print(f"FAILED: {', '.join(failed)}")
return 1
print("All packages passed.")
return 0
if __name__ == "__main__":
raise SystemExit(main())