-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
executable file
·91 lines (72 loc) · 2.74 KB
/
run_tests.py
File metadata and controls
executable file
·91 lines (72 loc) · 2.74 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
"""
Test runner script for combinatorial_codes package.
This script provides a convenient way to run different types of tests.
"""
import subprocess
import sys
import os
def run_command(command, description):
"""Run a command and print its description."""
print(f"\n{'='*50}")
print(f"🧪 {description}")
print(f"{'='*50}")
result = subprocess.run(command, shell=True, cwd=os.path.dirname(__file__))
if result.returncode == 0:
print(f"✅ {description} completed successfully!")
else:
print(f"❌ {description} failed with code {result.returncode}")
return result.returncode
def main():
"""Main test runner function."""
# Get the virtual environment python path
venv_python = "/Users/vui1/Documents/GitHub/combinatorial_codes/.venv/bin/python"
if len(sys.argv) > 1 and sys.argv[1] == "--help":
print("""
Usage: python run_tests.py [option]
Options:
--help Show this help message
--all Run all tests (default)
--milo Run only the Milo example tests
--fast Run quick tests only
--coverage Run tests with coverage report
Examples:
python run_tests.py # Run all tests
python run_tests.py --milo # Test Milo example only
python run_tests.py --coverage # Generate coverage report
""")
return
option = sys.argv[1] if len(sys.argv) > 1 else "--all"
if option == "--milo":
# Run only the Milo example tests
exit_code = run_command(
f"{venv_python} -m pytest tests/test_combinatorial_codes.py::TestExampleCodes::test_milo_example_simplicial_violators tests/test_combinatorial_codes.py::TestExampleCodes::test_milo_example_obstructions -v",
"Running Milo Example Tests"
)
elif option == "--fast":
# Run tests excluding slow ones
exit_code = run_command(
f"{venv_python} -m pytest tests/ -v -m 'not slow'",
"Running Fast Tests"
)
elif option == "--coverage":
# Run tests with coverage
exit_code = run_command(
f"{venv_python} -m pytest tests/ --cov=combinatorial_codes --cov-report=html --cov-report=term",
"Running Tests with Coverage"
)
else: # --all or default
# Run all tests
exit_code = run_command(
f"{venv_python} -m pytest tests/ -v",
"Running All Tests"
)
# Summary
print(f"\n{'='*50}")
if exit_code == 0:
print("🎉 All selected tests passed!")
else:
print("💥 Some tests failed. Check output above.")
print(f"{'='*50}\n")
sys.exit(exit_code)
if __name__ == "__main__":
main()