This commit was merged in pull request #898.
This commit is contained in:
@@ -277,6 +277,8 @@ def main() -> None:
|
||||
args.tests_passed = int(cr["tests_passed"])
|
||||
if not args.notes and cr.get("notes"):
|
||||
args.notes = cr["notes"]
|
||||
# Consume-once: delete after reading so stale results don't poison future cycles
|
||||
CYCLE_RESULT_FILE.unlink(missing_ok=True)
|
||||
|
||||
# Auto-detect issue from branch when not explicitly provided
|
||||
if args.issue is None:
|
||||
|
||||
@@ -58,6 +58,55 @@ class TestDetectIssueFromBranch:
|
||||
assert mod.detect_issue_from_branch() is None
|
||||
|
||||
|
||||
class TestConsumeOnce:
|
||||
"""cycle_result.json must be deleted after reading."""
|
||||
|
||||
def test_cycle_result_deleted_after_read(self, mod, tmp_path):
|
||||
"""After _load_cycle_result() data is consumed in main(), the file is deleted."""
|
||||
result_file = tmp_path / "cycle_result.json"
|
||||
result_file.write_text('{"issue": 42, "type": "bug"}')
|
||||
|
||||
with (
|
||||
patch.object(mod, "CYCLE_RESULT_FILE", result_file),
|
||||
patch.object(mod, "RETRO_FILE", tmp_path / "retro" / "cycles.jsonl"),
|
||||
patch.object(mod, "SUMMARY_FILE", tmp_path / "retro" / "summary.json"),
|
||||
patch.object(mod, "EPOCH_COUNTER_FILE", tmp_path / "retro" / ".epoch_counter"),
|
||||
patch(
|
||||
"sys.argv",
|
||||
["cycle_retro", "--cycle", "1", "--success", "--main-green", "--duration", "60"],
|
||||
),
|
||||
):
|
||||
mod.main()
|
||||
|
||||
assert not result_file.exists(), "cycle_result.json should be deleted after consumption"
|
||||
|
||||
def test_cycle_result_not_deleted_when_empty(self, mod, tmp_path):
|
||||
"""If cycle_result.json doesn't exist, no error occurs."""
|
||||
result_file = tmp_path / "nonexistent_result.json"
|
||||
|
||||
with (
|
||||
patch.object(mod, "CYCLE_RESULT_FILE", result_file),
|
||||
patch.object(mod, "RETRO_FILE", tmp_path / "retro" / "cycles.jsonl"),
|
||||
patch.object(mod, "SUMMARY_FILE", tmp_path / "retro" / "summary.json"),
|
||||
patch.object(mod, "EPOCH_COUNTER_FILE", tmp_path / "retro" / ".epoch_counter"),
|
||||
patch(
|
||||
"sys.argv",
|
||||
[
|
||||
"cycle_retro",
|
||||
"--cycle",
|
||||
"1",
|
||||
"--success",
|
||||
"--main-green",
|
||||
"--duration",
|
||||
"60",
|
||||
"--issue",
|
||||
"10",
|
||||
],
|
||||
),
|
||||
):
|
||||
mod.main() # Should not raise
|
||||
|
||||
|
||||
class TestBackfillExtractIssueNumber:
|
||||
"""Tests for backfill_retro.extract_issue_number PR-number filtering."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user