feat(ack): shard task records for merge-safe workspaces
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
"""从 .pouch/tester/cases/*.yaml 生成给人看的 cases.csv。不要手改 CSV。"""
|
||||
"""从 .pouch/tester/cases/*.yaml 生成给人看的 cases.csv。不要手改 CSV。
|
||||
|
||||
运行结果属于 runs/ 下的追加式记录,不回写本清单,避免多个工作区共同
|
||||
刷新运行状态造成合并冲突。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -32,11 +36,6 @@ FIELDS = (
|
||||
"how",
|
||||
"expected",
|
||||
"notes",
|
||||
"last_run",
|
||||
"last_result",
|
||||
"last_executed",
|
||||
"last_evidence",
|
||||
"last_notes",
|
||||
)
|
||||
|
||||
|
||||
@@ -148,28 +147,8 @@ def sort_cases(root: Path, cases: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
||||
)
|
||||
|
||||
|
||||
def last_run_lookup(root: Path) -> tuple[str, dict[str, dict[str, Any]]]:
|
||||
from generate_run_csv import latest_run_yaml, load_run, results_by_id
|
||||
|
||||
run_path = latest_run_yaml(root)
|
||||
if run_path is None:
|
||||
return "", {}
|
||||
try:
|
||||
run = load_run(run_path)
|
||||
except SystemExit:
|
||||
return "", {}
|
||||
try:
|
||||
rel = str(run_path.relative_to(root))
|
||||
except ValueError:
|
||||
rel = str(run_path)
|
||||
return rel, results_by_id(run)
|
||||
|
||||
|
||||
def export_cases_csv(root: Path, out: Path | None = None) -> Path:
|
||||
from generate_run_csv import executed_cell
|
||||
|
||||
cases = sort_cases(root, load_cases(root))
|
||||
last_run, last_by_id = last_run_lookup(root)
|
||||
path = out or (tester_dir(root) / "cases.csv")
|
||||
path.parent.mkdir(parents=True, exist_ok=True)
|
||||
with path.open("w", encoding="utf-8-sig", newline="") as handle:
|
||||
@@ -177,8 +156,6 @@ def export_cases_csv(root: Path, out: Path | None = None) -> Path:
|
||||
writer.writeheader()
|
||||
for case in cases:
|
||||
cid = str(case.get("id") or "")
|
||||
last = last_by_id.get(cid) or {}
|
||||
last_result = str(last.get("result") or "") if last else ""
|
||||
writer.writerow(
|
||||
{
|
||||
"category": case.get("category") or "",
|
||||
@@ -197,11 +174,6 @@ def export_cases_csv(root: Path, out: Path | None = None) -> Path:
|
||||
"how": how_brief(case.get("how")),
|
||||
"expected": one_line(case.get("expected")),
|
||||
"notes": one_line(case.get("notes")),
|
||||
"last_run": last_run if last else "",
|
||||
"last_result": last_result,
|
||||
"last_executed": executed_cell(last_result) if last else "",
|
||||
"last_evidence": one_line(last.get("evidence")) if last else "",
|
||||
"last_notes": one_line(last.get("notes")) if last else "",
|
||||
}
|
||||
)
|
||||
return path
|
||||
|
||||
Reference in New Issue
Block a user