131 lines
4.0 KiB
Python
131 lines
4.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
wikParse Test Runner
|
|
=====================
|
|
Run all test suites and provide comprehensive reporting.
|
|
"""
|
|
|
|
import sys
|
|
import subprocess
|
|
import pathlib
|
|
from typing import List, Dict
|
|
|
|
class TestRunner:
|
|
"""Run all test suites and aggregate results."""
|
|
|
|
def __init__(self):
|
|
self.test_suites = [
|
|
"test_transform_wiktionary.py",
|
|
"test_inflection_processor.py"
|
|
]
|
|
self.results = {}
|
|
|
|
def run_test_suite(self, test_file: str) -> bool:
|
|
"""Run a single test suite and return success status."""
|
|
print(f"\n{'='*60}")
|
|
print(f"RUNNING: {test_file}")
|
|
print('='*60)
|
|
|
|
test_path = pathlib.Path(__file__).parent / test_file
|
|
|
|
try:
|
|
result = subprocess.run(
|
|
[sys.executable, str(test_path)],
|
|
capture_output=True,
|
|
text=True,
|
|
timeout=300 # 5 minute timeout
|
|
)
|
|
|
|
print(result.stdout)
|
|
if result.stderr:
|
|
print("STDERR:", result.stderr)
|
|
|
|
success = result.returncode == 0
|
|
self.results[test_file] = {
|
|
"success": success,
|
|
"returncode": result.returncode
|
|
}
|
|
|
|
return success
|
|
|
|
except subprocess.TimeoutExpired:
|
|
print(f"❌ Test suite timed out: {test_file}")
|
|
self.results[test_file] = {
|
|
"success": False,
|
|
"returncode": -1,
|
|
"error": "timeout"
|
|
}
|
|
return False
|
|
|
|
except Exception as e:
|
|
print(f"❌ Error running test suite {test_file}: {e}")
|
|
self.results[test_file] = {
|
|
"success": False,
|
|
"returncode": -2,
|
|
"error": str(e)
|
|
}
|
|
return False
|
|
|
|
def run_all_tests(self) -> bool:
|
|
"""Run all test suites and return overall success status."""
|
|
print("\n" + "="*60)
|
|
print("WIKPARSE COMPREHENSIVE TEST SUITE")
|
|
print("="*60)
|
|
|
|
total_suites = len(self.test_suites)
|
|
passed_suites = 0
|
|
|
|
for test_file in self.test_suites:
|
|
if self.run_test_suite(test_file):
|
|
passed_suites += 1
|
|
|
|
# Print summary
|
|
print("\n" + "="*60)
|
|
print("FINAL TEST SUMMARY")
|
|
print("="*60)
|
|
|
|
for test_file, result in self.results.items():
|
|
status = "[PASS]" if result["success"] else "[FAIL]"
|
|
print(f"{status}: {test_file}")
|
|
|
|
print(f"\nTotal test suites: {total_suites}")
|
|
print(f"Passed: {passed_suites}")
|
|
print(f"Failed: {total_suites - passed_suites}")
|
|
|
|
if total_suites > 0:
|
|
success_rate = (passed_suites / total_suites) * 100
|
|
print(f"Success rate: {success_rate:.1f}%")
|
|
|
|
overall_success = passed_suites == total_suites
|
|
|
|
if overall_success:
|
|
print("\n[SUCCESS] ALL TEST SUITES PASSED!")
|
|
else:
|
|
print("\n[FAILED] SOME TEST SUITES FAILED!")
|
|
|
|
return overall_success
|
|
|
|
def list_available_tests(self):
|
|
"""List all available test suites."""
|
|
print("\nAvailable Test Suites:")
|
|
for i, test_file in enumerate(self.test_suites, 1):
|
|
print(f"{i}. {test_file}")
|
|
|
|
if __name__ == "__main__":
|
|
runner = TestRunner()
|
|
|
|
if len(sys.argv) > 1:
|
|
if sys.argv[1] == "--list":
|
|
runner.list_available_tests()
|
|
sys.exit(0)
|
|
elif sys.argv[1] == "--help":
|
|
print("Usage:")
|
|
print(" python run_all_tests.py - Run all tests")
|
|
print(" python run_all_tests.py --list - List available tests")
|
|
print(" python run_all_tests.py --help - Show this help")
|
|
sys.exit(0)
|
|
|
|
success = runner.run_all_tests()
|
|
|
|
# Exit with appropriate code
|
|
sys.exit(0 if success else 1) |