-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·77 lines (64 loc) · 1.99 KB
/
run_tests.py
File metadata and controls
executable file
·77 lines (64 loc) · 1.99 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
#!/usr/bin/env python3
"""
Test runner script for haskell-tree-sitter project.
Provides multiple ways to run tests with different levels of verbosity.
"""
import argparse
import subprocess
import sys
from pathlib import Path
def run_unittest():
"""Run tests using unittest discovery."""
print("Running tests with unittest...")
result = subprocess.run(
[sys.executable, "-m", "unittest", "discover", "tests/", "-v"],
cwd=Path(__file__).parent,
)
return result.returncode
def run_pytest():
"""Run tests using pytest (if available)."""
print("Running tests with pytest...")
try:
result = subprocess.run(
[sys.executable, "-m", "pytest", "tests/", "-v"], cwd=Path(__file__).parent
)
return result.returncode
except FileNotFoundError:
print("pytest not found. Install with: pip install pytest")
return 1
def run_coverage():
"""Run tests with coverage (if available)."""
print("Running tests with coverage...")
try:
result = subprocess.run(
[
sys.executable,
"-m",
"pytest",
"tests/",
"--cov=haskell_tree_sitter",
"--cov-report=term-missing",
],
cwd=Path(__file__).parent,
)
return result.returncode
except FileNotFoundError:
print("pytest-cov not found. Install with: pip install pytest-cov")
return 1
def main():
parser = argparse.ArgumentParser(description="Run tests for haskell-tree-sitter")
parser.add_argument(
"--runner",
choices=["unittest", "pytest", "coverage"],
default="unittest",
help="Test runner to use",
)
args = parser.parse_args()
if args.runner == "unittest":
return run_unittest()
elif args.runner == "pytest":
return run_pytest()
elif args.runner == "coverage":
return run_coverage()
if __name__ == "__main__":
sys.exit(main())