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