Spiritual_Health_Project / run_tests.py
DocUA's picture
feat: Complete prompt optimization system implementation
24214fc
#!/usr/bin/env python3
"""
Test runner script for organized test structure.
"""
import subprocess
import sys
from pathlib import Path
def run_test_suite(test_path, description):
"""Run a specific test suite."""
print(f"\nπŸ§ͺ {description}")
print("=" * 60)
try:
result = subprocess.run([
sys.executable, '-m', 'pytest',
str(test_path),
'-v', '--tb=short'
], capture_output=True, text=True)
if result.returncode == 0:
print(f"βœ… {description} - ALL PASSED")
# Count passed tests
lines = result.stdout.split('\n')
for line in lines:
if 'passed' in line and ('warning' in line or 'error' in line or line.strip().endswith('passed')):
print(f" {line.strip()}")
break
else:
print(f"❌ {description} - SOME FAILED")
print("STDOUT:", result.stdout[-500:]) # Last 500 chars
print("STDERR:", result.stderr[-500:]) # Last 500 chars
return result.returncode == 0
except Exception as e:
print(f"❌ Error running {description}: {e}")
return False
def main():
"""Run all test suites."""
print("πŸš€ Running Organized Test Suite")
print("=" * 60)
test_suites = [
('tests/prompt_optimization', 'Prompt Optimization Tests'),
('tests/integration', 'Integration Tests'),
('tests/unit', 'Unit Tests'),
('tests/verification_mode', 'Verification Mode Tests'),
('tests/chaplain_feedback', 'Chaplain Feedback Tests')
]
results = []
for test_path, description in test_suites:
if Path(test_path).exists():
success = run_test_suite(test_path, description)
results.append((description, success))
else:
print(f"⚠️ Skipping {description} - directory not found")
results.append((description, None))
# Summary
print("\n" + "=" * 60)
print("πŸ“Š TEST SUMMARY")
print("=" * 60)
passed = 0
failed = 0
skipped = 0
for description, success in results:
if success is True:
print(f"βœ… {description}")
passed += 1
elif success is False:
print(f"❌ {description}")
failed += 1
else:
print(f"⚠️ {description} (skipped)")
skipped += 1
print(f"\nπŸ“ˆ Results: {passed} passed, {failed} failed, {skipped} skipped")
if failed == 0:
print("πŸŽ‰ All test suites passed!")
return 0
else:
print("⚠️ Some test suites failed. Check output above.")
return 1
if __name__ == "__main__":
sys.exit(main())