|
| 1 | +""" |
| 2 | +Run all unit tests for the semantic-only workflow system. |
| 3 | +
|
| 4 | +This script runs all test modules and provides a summary. |
| 5 | +""" |
| 6 | + |
| 7 | +import subprocess |
| 8 | +import sys |
| 9 | + |
| 10 | + |
| 11 | +def run_test_file(test_file): |
| 12 | + """Run a single test file and return (passed, failed)""" |
| 13 | + print(f'\n{"=" * 80}') |
| 14 | + print(f'Running {test_file}') |
| 15 | + print(f'{"=" * 80}') |
| 16 | + |
| 17 | + result = subprocess.run(['uv', 'run', 'python', f'workflows/tests/{test_file}'], capture_output=True, text=True) |
| 18 | + |
| 19 | + # Print output |
| 20 | + print(result.stdout) |
| 21 | + if result.stderr: |
| 22 | + print(result.stderr) |
| 23 | + |
| 24 | + # Parse results from output |
| 25 | + for line in result.stdout.split('\n'): |
| 26 | + if 'Test Results:' in line: |
| 27 | + # Extract passed and failed counts |
| 28 | + # Format: "Test Results: X passed, Y failed" |
| 29 | + parts = line.split(':')[1].strip().split(',') |
| 30 | + passed = int(parts[0].split()[0]) |
| 31 | + failed = int(parts[1].split()[0]) |
| 32 | + return (passed, failed) |
| 33 | + |
| 34 | + # If we couldn't parse, check exit code |
| 35 | + if result.returncode == 0: |
| 36 | + return (1, 0) # Assume some tests passed |
| 37 | + else: |
| 38 | + return (0, 1) # Assume some tests failed |
| 39 | + |
| 40 | + |
| 41 | +def main(): |
| 42 | + """Run all tests and provide summary""" |
| 43 | + test_files = [ |
| 44 | + 'test_selector_generator.py', |
| 45 | + 'test_element_finder.py', |
| 46 | + 'test_workflow_execution.py', |
| 47 | + ] |
| 48 | + |
| 49 | + print('\n' + '=' * 80) |
| 50 | + print('SEMANTIC-ONLY WORKFLOW SYSTEM - UNIT TEST SUITE') |
| 51 | + print('=' * 80) |
| 52 | + |
| 53 | + total_passed = 0 |
| 54 | + total_failed = 0 |
| 55 | + |
| 56 | + results = [] |
| 57 | + |
| 58 | + for test_file in test_files: |
| 59 | + passed, failed = run_test_file(test_file) |
| 60 | + total_passed += passed |
| 61 | + total_failed += failed |
| 62 | + results.append((test_file, passed, failed)) |
| 63 | + |
| 64 | + # Print summary |
| 65 | + print('\n' + '=' * 80) |
| 66 | + print('TEST SUITE SUMMARY') |
| 67 | + print('=' * 80) |
| 68 | + |
| 69 | + for test_file, passed, failed in results: |
| 70 | + status = '✅ PASS' if failed == 0 else '❌ FAIL' |
| 71 | + print(f'{status} {test_file:40s} {passed:3d} passed, {failed:3d} failed') |
| 72 | + |
| 73 | + print(f'\n{"=" * 80}') |
| 74 | + print(f'TOTAL: {total_passed} passed, {total_failed} failed') |
| 75 | + print(f'{"=" * 80}\n') |
| 76 | + |
| 77 | + if total_failed > 0: |
| 78 | + print('❌ Some tests failed!') |
| 79 | + sys.exit(1) |
| 80 | + else: |
| 81 | + print('✅ All tests passed!') |
| 82 | + sys.exit(0) |
| 83 | + |
| 84 | + |
| 85 | +if __name__ == '__main__': |
| 86 | + main() |
0 commit comments