Answer stability round 1: 1 🔴, 4 🟡 (1 misread); run chunk-pr by its path, say why a clean left the worktree, test the working-branch move

This commit is contained in:
2026-12-03 14:02:59 +01:00
parent e8ab4ef9d8
commit 57fef64105
4 changed files with 44 additions and 18 deletions
+10 -4
View File
@@ -1,5 +1,6 @@
import contextlib
import io
import os
import pathlib
import sys
import tempfile
@@ -8,6 +9,7 @@ import unittest
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
from do_epic.parking import CHUNK_PR
from do_epic import chunk_prompt, parked
from failure import Failure
from loop_effects.doubles import FakeEffects
@@ -62,26 +64,30 @@ class TheCleanupOfAChunkWhosePullRequestIsNoLongerOpen(unittest.TestCase):
def forge_at(self, folder: str):
def run(command: list[str]) -> str | Failure:
self.ran.append((folder, command))
return self.clean if command[0] == "chunk-pr" else self.listed
return self.clean if command[0] == CHUNK_PR else self.listed
return run
def cleaned(self) -> tuple[Merged | Stop | None, str]:
def cleaned(self) -> tuple[Merged | Stop | Unopened, str]:
out = io.StringIO()
with contextlib.redirect_stdout(out):
return merged_and_cleaned(self.poll, UNOPENED), out.getvalue()
def test_chunk_pr_is_run_by_a_path_that_exists_since_do_epics_path_does_not_hold_it(self) -> None:
path = pathlib.Path(CHUNK_PR)
self.assertTrue(path.is_absolute() and path.is_file() and os.access(path, os.X_OK), CHUNK_PR)
def test_a_clean_that_removed_the_worktree_finishes_the_chunk_and_unparks_it(self) -> None:
done, out = self.cleaned()
self.assertEqual(done, Merged())
self.assertIn(" pull request merged: removed /code/api-ABC-20\n", out)
self.assertEqual(self.ran[0], ("/code/api-ABC-20", ["chunk-pr", "clean"]))
self.assertEqual(self.ran[0], ("/code/api-ABC-20", [CHUNK_PR, "clean"]))
self.assertEqual(parked.parked_chunks(self.folder), {})
def test_a_clean_that_failed_with_the_worktree_standing_leaves_the_chunk_to_its_worker(self) -> None:
self.clean = Failure("chunk-pr clean: no merged pull request")
self.listed = "worktree /code/api\nbranch refs/heads/main\n\nworktree /code/api-ABC-20\nbranch refs/heads/ABC-20\n"
done, out = self.cleaned()
self.assertEqual((done, out), (None, ""))
self.assertEqual((done, out), (Unopened("no pull request is open; chunk-pr clean: no merged pull request", "/code/api-ABC-20"), ""))
self.assertEqual(self.ran[1], ("/code/api", ["git", "worktree", "list", "--porcelain"]))
self.assertEqual(list(parked.parked_chunks(self.folder)), ["ABC-20"])