-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_phase2_modules.py
More file actions
executable file
Β·135 lines (111 loc) Β· 3.95 KB
/
test_phase2_modules.py
File metadata and controls
executable file
Β·135 lines (111 loc) Β· 3.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env python3
"""
Quick validation script for Phase 2 test modules
"""
import subprocess
import sys
import time
import json
from pathlib import Path
def run_test_module(module_name):
"""Run a specific test module and return results"""
print(f"\nπ§ͺ Testing {module_name}...")
print("=" * 60)
start_time = time.time()
try:
# Run the test with JSON output
result = subprocess.run(
[sys.executable, "run_tests.py", "--filter", module_name, "--json", f"reports/phase2_{module_name}.json"],
capture_output=True,
text=True,
timeout=120 # 2 minute timeout
)
duration = time.time() - start_time
# Parse output to get summary
if result.returncode == 0:
# Try to read the JSON report
report_path = Path(f"reports/phase2_{module_name}.json")
if report_path.exists():
with open(report_path) as f:
report = json.load(f)
summary = report.get("summary", {})
print(f"β
{module_name}: PASSED")
print(f" Total Tests: {summary.get('total_tests', 0)}")
print(f" Passed: {summary.get('passed', 0)}")
print(f" Failed: {summary.get('failed', 0)}")
print(f" Success Rate: {summary.get('success_rate', 0):.1f}%")
else:
print(f"β
{module_name}: Completed (no report found)")
else:
print(f"β {module_name}: FAILED")
print(f" Error: {result.stderr[:200]}")
print(f" Duration: {duration:.2f}s")
return {
"module": module_name,
"success": result.returncode == 0,
"duration": duration,
"output": result.stdout,
"error": result.stderr
}
except subprocess.TimeoutExpired:
print(f"β {module_name}: TIMEOUT")
return {
"module": module_name,
"success": False,
"duration": 120,
"error": "Test timed out after 120 seconds"
}
except Exception as e:
print(f"β {module_name}: ERROR - {str(e)}")
return {
"module": module_name,
"success": False,
"duration": time.time() - start_time,
"error": str(e)
}
def main():
"""Run all Phase 2 test modules"""
print("π Phase 2 Test Module Validation")
print("=" * 60)
# Phase 2 modules
modules = [
"context_policy",
"code_graph",
"playbooks",
"patterns"
]
# Create reports directory
Path("reports").mkdir(exist_ok=True)
# Run all tests
results = []
total_start = time.time()
for module in modules:
result = run_test_module(module)
results.append(result)
total_duration = time.time() - total_start
# Summary
print("\nπ Phase 2 Test Summary")
print("=" * 60)
successful = sum(1 for r in results if r["success"])
failed = len(results) - successful
print(f"Total Modules: {len(results)}")
print(f"β
Successful: {successful}")
print(f"β Failed: {failed}")
print(f"Total Duration: {total_duration:.2f}s")
# Save summary report
summary_report = {
"phase": "Phase 2 Test Implementation",
"timestamp": time.strftime("%Y-%m-%d %H:%M:%S"),
"total_modules": len(results),
"successful": successful,
"failed": failed,
"duration": total_duration,
"results": results
}
with open("reports/phase2_validation_summary.json", "w") as f:
json.dump(summary_report, f, indent=2)
print(f"\nπ Summary report saved to: reports/phase2_validation_summary.json")
# Exit code based on success
sys.exit(0 if failed == 0 else 1)
if __name__ == "__main__":
main()