first commit
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
from experiments.scripts.rebuttal_monitor import (
|
||||
RebuttalTarget,
|
||||
build_target_status,
|
||||
safe_json_dump,
|
||||
)
|
||||
|
||||
|
||||
def test_build_target_status_reads_manifest_progress_and_log(tmp_path: Path) -> None:
|
||||
worktree = tmp_path / "rebuttle-ecip"
|
||||
state_dir = tmp_path / "state"
|
||||
run_root = worktree / "workspace" / "experiments" / "runs" / "run1"
|
||||
run_root.mkdir(parents=True)
|
||||
log_path = tmp_path / "ecip.log"
|
||||
log_path.write_text("line one\nline two\n", encoding="utf-8")
|
||||
|
||||
safe_json_dump(
|
||||
{
|
||||
"run_id": "run1",
|
||||
"status": "running",
|
||||
"updated_at": "2026-03-22T12:00:00+00:00",
|
||||
"total_cases": 8,
|
||||
"completed_cases": 3,
|
||||
"success": 2,
|
||||
"failed": 1,
|
||||
"running_case_ids": ["simple/0000/0004"],
|
||||
"pending_case_ids": ["simple/0000/0005"],
|
||||
"skipped_existing": 2,
|
||||
},
|
||||
run_root / "progress.json",
|
||||
)
|
||||
safe_json_dump(
|
||||
{
|
||||
"run_id": "run1",
|
||||
"total_cases": 8,
|
||||
"success": 2,
|
||||
"failed": 1,
|
||||
},
|
||||
run_root / "summary.json",
|
||||
)
|
||||
safe_json_dump(
|
||||
{
|
||||
"target": "ecip",
|
||||
"branch": "rebuttle/ecip",
|
||||
"worktree_path": str(worktree),
|
||||
"run_id": "run1",
|
||||
"pid": 999999,
|
||||
"execution_root": str(worktree / "workspace"),
|
||||
"run_root": str(run_root),
|
||||
"output_root": str(
|
||||
worktree / "workspace" / "experiments" / "output_test" / "run1"
|
||||
),
|
||||
"log_path": str(log_path),
|
||||
"started_at": "2026-03-22T11:59:00+00:00",
|
||||
"updated_at": "2026-03-22T12:00:00+00:00",
|
||||
},
|
||||
state_dir / "ecip.json",
|
||||
)
|
||||
|
||||
status = build_target_status(
|
||||
RebuttalTarget(
|
||||
name="ecip",
|
||||
branch="rebuttle/ecip",
|
||||
worktree_path=str(worktree),
|
||||
),
|
||||
state_dir=state_dir,
|
||||
log_line_count=5,
|
||||
)
|
||||
|
||||
assert status["target"] == "ecip"
|
||||
assert status["run_id"] == "run1"
|
||||
assert status["summary"]["success"] == 2
|
||||
assert status["progress"]["running_case_ids"] == ["simple/0000/0004"]
|
||||
assert status["log_tail"] == ["line one", "line two"]
|
||||
assert status["status"] in {"running", "stopped", "finished"}
|
||||
Reference in New Issue
Block a user