diff options
Diffstat (limited to 'tests/test_split.py')
| -rw-r--r-- | tests/test_split.py | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_split.py b/tests/test_split.py index 9d19308..f8495eb 100644 --- a/tests/test_split.py +++ b/tests/test_split.py @@ -290,6 +290,43 @@ class OrchSplitTest(SplitCli): self.assertIn(f" {self.sha(self.code)} ", (self.root / "out" / "wf-orch.log").read_text()) + def _finish_then_dirty_books(self): + self.wf("orch", "pick", "fast", "--id", "t-three", project=False, env=IDENT) + wt = self.code / ".worktrees" / "fast" + self.wf("start", "t-three", "--worktree", str(wt), "--branch", "fast/t-three", project=False, env=IDENT) + (wt / "code.txt").write_text("x\n") + code, out, err = self.wf("finish", "t-three", "-m", "ok", "--commit", "impl", "code.txt", + project=False, cwd=wt, env=IDENT) + self.assertEqual(code, 0, out + err) + self.wf("note", "t-one", "later edit", project=False, env=IDENT) # books dirty in the private tree + self.assertTrue(subprocess.run(["git", "status", "--porcelain", "TASKS.md"], cwd=self.root, + capture_output=True, text=True).stdout.strip()) + + def test_post_done_commits_leftover_books_with_code_sha(self): + self._finish_then_dirty_books() + csha = self.sha(self.code) + code, out, err = self.wf("orch", "post", "t-three", "fast", "--result", "done", "--commit", csha, + "--no-pick", project=False, env=IDENT) + self.assertEqual(code, 0, out + err) + self.assertEqual(self.log(self.root).splitlines()[:2], [f"t-three done (code {csha})"] * 2) + self.assertFalse(subprocess.run(["git", "status", "--porcelain", "TASKS.md"], cwd=self.root, + capture_output=True, text=True).stdout.strip()) + self.assertIn(f" t-three done {csha} ", (self.root / "out" / "wf-orch.log").read_text()) + + def test_post_stale_private_sha_replaced_by_code_sha(self): + self._finish_then_dirty_books() + stale = self.sha(self.root) # worker reported the private repo's HEAD + code, out, err = self.wf("orch", "post", "t-three", "fast", "--result", "done", "--commit", stale, + "--no-pick", project=False, env=IDENT) + self.assertEqual(code, 0, out + err) + csha = self.sha(self.code) + self.assertIn(f"commit {stale} not in code repo", out) + self.assertIn(f" t-three done {csha} ", (self.root / "out" / "wf-orch.log").read_text()) + self.assertEqual(self.log(self.root).splitlines()[:2], [f"t-three done (code {csha})"] * 2) + self.assertFalse(subprocess.run(["git", "status", "--porcelain", "TASKS.md"], cwd=self.root, + capture_output=True, text=True).stdout.strip()) + + class CheckSplitTest(SplitCli): def test_cloud_error_push_and_ignore_warnings(self): (self.root / "workflow.toml").write_text(SplitCli.toml + "cloud = true\n") |
