-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·98 lines (83 loc) · 2.69 KB
/
test.py
File metadata and controls
executable file
·98 lines (83 loc) · 2.69 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/usr/bin/env python3
"""
Test runner script for Ryx ORM.
This script provides convenient commands to run different test suites.
"""
import argparse
import subprocess
import sys
from pathlib import Path
def run_command(cmd, cwd=None):
"""Run a command and return the result."""
try:
result = subprocess.run(
cmd,
shell=True,
cwd=cwd or Path(__file__).parent,
capture_output=True,
text=True,
check=True
)
return result
except subprocess.CalledProcessError as e:
print(f"Command failed: {cmd}")
print(f"STDOUT: {e.stdout}")
print(f"STDERR: {e.stderr}")
sys.exit(1)
def main():
parser = argparse.ArgumentParser(description="Ryx ORM Test Runner")
parser.add_argument(
"command",
choices=["unit", "integration", "all", "coverage", "check"],
help="Test command to run"
)
parser.add_argument(
"--verbose", "-v",
action="store_true",
help="Verbose output"
)
parser.add_argument(
"--no-cov",
action="store_true",
help="Skip coverage for coverage command"
)
args = parser.parse_args()
# Ensure we're in development mode
print("Ensuring Rust extension is built...")
run_command("maturin develop")
base_cmd = "python -m pytest"
if args.verbose:
base_cmd += " -v"
if args.command == "unit":
print("Running unit tests...")
cmd = f"{base_cmd} tests/unit/"
run_command(cmd)
elif args.command == "integration":
print("Running integration tests...")
cmd = f"{base_cmd} tests/integration/"
run_command(cmd)
elif args.command == "all":
print("Running all tests...")
cmd = f"{base_cmd} tests/"
run_command(cmd)
elif args.command == "coverage":
print("Running tests with coverage...")
if args.no_cov:
cmd = f"{base_cmd} tests/"
else:
cmd = f"{base_cmd} --cov=ryx --cov-report=html --cov-report=term tests/"
run_command(cmd)
if not args.no_cov:
print("Coverage report generated in htmlcov/index.html")
elif args.command == "check":
print("Running code quality checks...")
# Run tests with coverage
run_command(f"{base_cmd} --cov=ryx --cov-report=term-missing tests/")
# Check for unused imports, etc. (if tools are available)
try:
run_command("python -m flake8 ryx/ tests/ --max-line-length=100")
except FileNotFoundError:
print("flake8 not installed, skipping style checks")
print("✓ All tests passed!")
if __name__ == "__main__":
main()