#!/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())