feat(ppclock): batch JSONL 批量执行(单连接),104 测试全绿

This commit is contained in:
agent committed 2026-07-24 11:03:36 +00:00
1 parent f291c61676
commit 5ff399673a
6 files changed
+906 -71

No files matched your search

+26
View File
@@ -165,3 +165,29 @@ class TestCommands:
assert code == 0
t = FakeTransport.instances[0]
assert len(t.epd_writes) == 63 + 63 + 1 # 默认三色双平面
class TestBatch:
def test_batch_jsonl(self, capsys, tmp_path):
f = tmp_path / "job.jsonl"
f.write_text(
'{"argv": ["mode", "clock1"]}\n'
'{"argv": ["parking", "12"]}\n'
'{"argv": ["countdown"]}\n' # 故意错误行
)
code, out = run_cli(capsys, ["--json", "batch", str(f)])
assert code == 0
results = out["data"]["results"]
assert [r["ok"] for r in results] == [True, True, False]
# 单连接:只有1个 transport 实例
assert len(FakeTransport.instances) == 1
def test_batch_stop_on_error(self, capsys, tmp_path):
f = tmp_path / "job.jsonl"
f.write_text(
'{"argv": ["countdown"]}\n'
'{"argv": ["mode", "clock1"]}\n'
)
code, out = run_cli(capsys, ["--json", "batch", str(f), "--stop-on-error"])
results = out["data"]["results"]
assert len(results) == 1 and results[0]["ok"] is False