|
| 1 | +#!/usr/bin/env python3 |
| 2 | +"""Test runner script for freee_a11y_gl tests.""" |
| 3 | + |
| 4 | +import subprocess |
| 5 | +import sys |
| 6 | + |
| 7 | + |
| 8 | +def run_tests(): |
| 9 | + """Run all tests and provide a summary.""" |
| 10 | + |
| 11 | + test_suites = [ |
| 12 | + ("Core Config Tests", "tests/core/test_config.py"), |
| 13 | + ("Core Utils Tests", "tests/core/test_utils.py"), |
| 14 | + ("Base Model Tests", "tests/models/test_base.py"), |
| 15 | + ("Check Model Tests", "tests/models/test_check.py"), |
| 16 | + ("FAQ Article Tests", "tests/models/test_faq_article.py"), |
| 17 | + ("Guideline Tests", "tests/models/test_guideline.py"), |
| 18 | + ("Info Reference Tests", "tests/models/test_info_ref.py"), |
| 19 | + ("FAQ Tag Tests", "tests/models/faq/test_tag.py"), |
| 20 | + ("RelationshipManager Tests", "tests/managers/test_relationship_manager.py"), |
| 21 | + ("YAML Processor Tests", "tests/yaml_processor/test_process_yaml.py"), |
| 22 | + ("RST Processor Tests", "tests/yaml_processor/test_rst_processor.py"), |
| 23 | + ] |
| 24 | + |
| 25 | + results = [] |
| 26 | + |
| 27 | + for name, test_path in test_suites: |
| 28 | + print(f"\n{'='*60}") |
| 29 | + print(f"Running {name}") |
| 30 | + print('='*60) |
| 31 | + |
| 32 | + try: |
| 33 | + result = subprocess.run( |
| 34 | + [sys.executable, "-m", "pytest", test_path, "-v"], |
| 35 | + capture_output=True, |
| 36 | + text=True, |
| 37 | + cwd="/home/max/work/a11y-guidelines/tools/lib/freee_a11y_gl" |
| 38 | + ) |
| 39 | + |
| 40 | + if result.returncode == 0: |
| 41 | + print(f"✅ {name}: PASSED") |
| 42 | + results.append((name, "PASSED", "")) |
| 43 | + else: |
| 44 | + print(f"❌ {name}: FAILED") |
| 45 | + results.append((name, "FAILED", result.stdout + result.stderr)) |
| 46 | + |
| 47 | + except Exception as e: |
| 48 | + print(f"💥 {name}: ERROR - {e}") |
| 49 | + results.append((name, "ERROR", str(e))) |
| 50 | + |
| 51 | + # Summary |
| 52 | + print(f"\n{'='*60}") |
| 53 | + print("TEST SUMMARY") |
| 54 | + print('='*60) |
| 55 | + |
| 56 | + passed = sum(1 for _, status, _ in results if status == "PASSED") |
| 57 | + failed = sum(1 for _, status, _ in results if status == "FAILED") |
| 58 | + errors = sum(1 for _, status, _ in results if status == "ERROR") |
| 59 | + |
| 60 | + for name, status, output in results: |
| 61 | + icon = "✅" if status == "PASSED" else "❌" if status == "FAILED" else "💥" |
| 62 | + print(f"{icon} {name}: {status}") |
| 63 | + if status != "PASSED" and output: |
| 64 | + print(f" {output[:200]}...") |
| 65 | + |
| 66 | + print(f"\nTotal: {len(results)} test suites") |
| 67 | + print(f"Passed: {passed}") |
| 68 | + print(f"Failed: {failed}") |
| 69 | + print(f"Errors: {errors}") |
| 70 | + |
| 71 | + return failed + errors == 0 |
| 72 | + |
| 73 | + |
| 74 | +if __name__ == "__main__": |
| 75 | + success = run_tests() |
| 76 | + sys.exit(0 if success else 1) |
0 commit comments