aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/tests/test_split.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_split.py')
-rw-r--r--tests/test_split.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/test_split.py b/tests/test_split.py
index 2026e33..346c138 100644
--- a/tests/test_split.py
+++ b/tests/test_split.py
@@ -1,3 +1,4 @@
+import os
import subprocess
import unittest
from pathlib import Path
@@ -72,3 +73,39 @@ class DiscoveryTest(SplitCli):
self.assertFalse(cfg.split)
self.assertIsNone(config.code_main(cfg))
self.assertEqual(cfg.push, ["true"])
+
+
+class StartSplitTest(SplitCli):
+ toml = SplitCli.toml + 'worktree_setup = ["pwd > where.txt"]\n'
+
+ def test_start_makes_code_worktree_with_wf_home(self):
+ wt = self.code / ".worktrees" / "slow"
+ code, out, err = self.wf("start", "t-three", "--worktree", str(wt), "--branch", "slow/t-three",
+ project=False, env=IDENT)
+ self.assertEqual(code, 0, out + err)
+ self.assertEqual((wt / ".wf-home").read_text(), f"{self.root}\n")
+ self.assertEqual(subprocess.run(["git", "branch", "--show-current"], cwd=wt, capture_output=True,
+ text=True).stdout.strip(), "slow/t-three")
+ self.assertEqual((wt / "where.txt").read_text().strip(), str(wt)) # setup cwd = code worktree
+ self.assertIn("(in progress: slow/t-three)", (self.root / "TASKS.md").read_text())
+ self.assertIn(f"cd {wt} && (make test) && ", out)
+ self.assertFalse((self.root / ".worktrees").exists()) # nothing in the private repo
+
+ def test_setup_in_code_worktree(self):
+ wt = self.add_wt()
+ code, out, err = self.wf("setup", project=False, cwd=wt)
+ self.assertEqual(code, 0, err)
+ self.assertEqual((wt / "where.txt").read_text().strip(), str(wt))
+
+ def env(self, name, pid): # copy of tests/test_claims.py ClaimTest.env
+ sock = self.root / f"{name}.sock"
+ sock.write_text("")
+ return {"CLAUDE_CODE_MESSAGING_SOCKET": str(sock), "CLAUDE_PID": str(pid), "CLAUDE_CODE_SESSION_ID": name}
+
+ def test_next_advice_names_wf_start_in_code_repo(self):
+ # pattern: tests/test_claims.py::test_next_says_worktree_mode_when_two_sessions_live
+ son, me = self.env("s", os.getppid()), self.env("o", os.getpid())
+ self.wf("next", "--lane", "slow", "--as", "sonnet", "--brief", env=son)
+ code, out, err = self.wf("next", "--lane", "fast", "--as", "opus", env=me)
+ self.assertIn(f" wf start <task> --worktree {self.code / '.worktrees' / 'fast'} --branch fast/<task> "
+ f"(run in {self.root}; wf there writes this TASKS.md)\n", out)