29 lines
1.1 KiB
Python
29 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from control_plane.projects.models import Artifact, Project, Task
|
|
from control_plane.verification.models import TestRun
|
|
from tools.capabilities import Capability
|
|
from tools.runtime import WorktreeTools
|
|
|
|
|
|
class DeterministicTestRunner:
|
|
def run(self, project: Project, task: Task, worktree_path: Path, command: list[str]) -> TestRun:
|
|
tools = WorktreeTools(worktree_path, {Capability.RUN_TESTS})
|
|
result = tools.run(command, timeout=120)
|
|
artifact = Artifact.objects.create(
|
|
project=project,
|
|
task=task,
|
|
artifact_type="test_report",
|
|
name=f"task-{task.id}-tests",
|
|
content={"stdout": result.stdout, "stderr": result.stderr, "returncode": result.returncode},
|
|
generated_by="deterministic_test_runner",
|
|
)
|
|
return TestRun.objects.create(
|
|
project=project,
|
|
task=task,
|
|
command=" ".join(command),
|
|
status="PASS" if result.returncode == 0 else "FAIL",
|
|
output_artifact=artifact,
|
|
)
|