-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·97 lines (73 loc) · 2.65 KB
/
run_tests.py
File metadata and controls
executable file
·97 lines (73 loc) · 2.65 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
#!/usr/bin/env python3
"""
Copyright (c) 2025 Dan Vatca
Test runner for FastMarkDocs library.
This script provides a convenient way to run different types of tests
with various options and configurations.
"""
import argparse
import subprocess
import sys
def run_command(cmd, description):
"""Run a command and handle the result."""
print(f"\n🔍 {description}")
print(f"Running: {' '.join(cmd)}")
print("-" * 50)
result = subprocess.run(cmd, capture_output=False)
if result.returncode == 0:
print(f"✅ {description} - PASSED")
else:
print(f"❌ {description} - FAILED")
return False
return True
def main():
"""Main test runner function."""
parser = argparse.ArgumentParser(description="Run tests for FastMarkDocs library")
parser.add_argument(
"--type", choices=["unit", "integration", "all"], default="all", help="Type of tests to run (default: all)"
)
parser.add_argument("--coverage", action="store_true", help="Run tests with coverage reporting")
parser.add_argument("--verbose", "-v", action="store_true", help="Verbose output")
parser.add_argument("--fast", action="store_true", help="Skip slow tests")
parser.add_argument("--parallel", "-n", type=int, help="Run tests in parallel (specify number of workers)")
parser.add_argument("--pattern", help="Run tests matching pattern")
args = parser.parse_args()
# Base pytest command
cmd = ["python", "-m", "pytest"]
# Add test type selection
if args.type == "unit":
cmd.extend(["tests/unit"])
elif args.type == "integration":
cmd.extend(["tests/integration"])
else:
cmd.extend(["tests"])
# Add coverage if requested
if args.coverage:
cmd.extend(
["--cov=src/fastmarkdocs", "--cov-report=html:htmlcov", "--cov-report=term-missing", "--cov-report=xml"]
)
# Add verbosity
if args.verbose:
cmd.append("-vv")
# Skip slow tests if requested
if args.fast:
cmd.extend(["-m", "not slow"])
# Add parallel execution
if args.parallel:
cmd.extend(["-n", str(args.parallel)])
# Add pattern matching
if args.pattern:
cmd.extend(["-k", args.pattern])
# Run the tests
success = run_command(cmd, f"Running {args.type} tests")
if not success:
print("\n❌ Tests failed!")
sys.exit(1)
print("\n✅ All tests passed!")
# Show coverage report location if coverage was run
if args.coverage:
print("\n📊 Coverage report generated:")
print(" - HTML: htmlcov/index.html")
print(" - XML: coverage.xml")
if __name__ == "__main__":
main()