-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.py
More file actions
37 lines (31 loc) · 1.36 KB
/
Copy pathrun_tests.py
File metadata and controls
37 lines (31 loc) · 1.36 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
#!/usr/bin/env python3
import unittest
import sys
import os
def run_all_tests() -> None:
"""Automatically discover and run all unit tests inside the tests directory."""
print("━━━ ⚡ CRASH_SIGHT AUTOMATED TEST RUNNER ⚡ ━━━\n")
# Ensure the root directory is in sys.path for secure module imports
current_dir = os.path.abspath(os.path.dirname(__file__))
if current_dir not in sys.path:
sys.path.insert(0, current_dir)
# Discovery engine: find all files matching 'test_*.py' inside the 'tests' folder
tests_dir = os.path.join(current_dir, "tests")
loader = unittest.defaultTestLoader
suite = loader.discover(start_dir=tests_dir, pattern="test_*.py")
# Run the test suite with a high verbosity level
runner = unittest.TextTestRunner(verbosity=2)
result = runner.run(suite)
# Final status indicator (Highly useful for CI/CD pipelines or GitHub Actions)
if result.wasSuccessful():
print("\n" + "═" * 60)
print("✅ SUCCESS: All tests executed and passed successfully!")
print("═" * 60)
sys.exit(0)
else:
print("\n" + "═" * 60)
print(f"❌ FAILURE: Test suite failed with {len(result.failures)} failures and {len(result.errors)} errors.")
print("═" * 60)
sys.exit(1)
if __name__ == "__main__":
run_all_tests()