91 lines
2.6 KiB
Python
91 lines
2.6 KiB
Python
"""Full E2E Test: Plan → Code → Review with real Gemini CLI.
|
|
|
|
Tests the complete pipeline against a concrete improvement task.
|
|
"""
|
|
|
|
import sys
|
|
import io
|
|
import asyncio
|
|
import json
|
|
import time
|
|
import os
|
|
|
|
if sys.stdout.encoding != "utf-8":
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding="utf-8", errors="replace")
|
|
|
|
# 프로젝트 루트를 동적으로 결정 (tests/ 상위 디렉토리)
|
|
PROJECT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
|
sys.path.insert(0, PROJECT)
|
|
|
|
from core.task_pipeline import TaskPipeline
|
|
|
|
USER_REQUEST = (
|
|
"project_indexer.py의 find_relevant 함수가 공백이 포함된 쿼리를 처리하지 못합니다. "
|
|
"'gemini caller'로 검색하면 gemini_caller.py를 찾지 못합니다. "
|
|
"밑줄과 공백을 동일하게 처리하도록 개선해주세요."
|
|
)
|
|
|
|
|
|
async def main():
|
|
start = time.time()
|
|
pipeline = TaskPipeline(PROJECT, token_budget=15_000)
|
|
pipeline.setup()
|
|
|
|
# === PHASE 1: Plan ===
|
|
print("=" * 60)
|
|
print("PHASE 1: PLANNER")
|
|
print("=" * 60)
|
|
|
|
plan = await pipeline.plan(USER_REQUEST)
|
|
tasks = plan.get("tasks", [])
|
|
|
|
print(f"Summary: {plan.get('summary', 'N/A')}")
|
|
print(f"Tasks: {len(tasks)}")
|
|
for t in tasks:
|
|
print(f" [{t.get('id')}] {t.get('title')}")
|
|
print(f" Files: {t.get('files')}")
|
|
print(f" Risk: {plan.get('risk', 'N/A')}")
|
|
|
|
if not tasks:
|
|
print("❌ No tasks returned, stopping.")
|
|
return
|
|
|
|
# === PHASE 2: Code (first task only) ===
|
|
print(f"\n{'=' * 60}")
|
|
print("PHASE 2: CODER (Task 1 only)")
|
|
print("=" * 60)
|
|
|
|
first_task = tasks[0]
|
|
code_output = await pipeline.code(first_task)
|
|
|
|
print(f"Output length: {len(code_output)} chars")
|
|
print(f"First 800 chars:")
|
|
print(code_output[:800])
|
|
print("...")
|
|
|
|
# === PHASE 3: Review ===
|
|
print(f"\n{'=' * 60}")
|
|
print("PHASE 3: REVIEWER")
|
|
print("=" * 60)
|
|
|
|
review = await pipeline.review(first_task, code_output)
|
|
|
|
print(f"Passed: {review.get('passed', 'N/A')}")
|
|
if review.get("issues"):
|
|
for issue in review["issues"]:
|
|
print(f" [{issue.get('severity')}] {issue.get('description', '')[:80]}")
|
|
print(f"Summary: {review.get('summary', 'N/A')[:200]}")
|
|
|
|
# === Results ===
|
|
elapsed = time.time() - start
|
|
print(f"\n{'=' * 60}")
|
|
print(f"RESULTS")
|
|
print(f" Gemini calls: {pipeline.gemini.call_count}")
|
|
print(f" Total time: {elapsed:.1f}s")
|
|
print(f" Pipeline log entries: {len(pipeline.log)}")
|
|
print(f"✅ Full E2E test complete!")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|