test: make sibling-worktree skip test hermetic (closes #283)

test_skip_scan_walk_root_skips_sibling_worktrees_only derived its
fixture paths from __file__, so the branches/ sibling-worktree skip
assertion only held when the suite ran from a branches/<slug> worktree
whose orchestration checkout has a real branches/ directory —
skip_python_scan_walk_root skips a branches/ walk root only when
<project_root>/branches exists on disk. From the main checkout or any
plain clone the test failed with 'AssertionError: False is not true'.

Build the <main>/branches/<worktree> layout in a TemporaryDirectory and
assert against those paths instead. All four behavioural assertions are
preserved and no production code changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This commit is contained in:
2026-07-07 00:19:43 -04:00
co-authored by Claude Opus 4.8
parent d6f4f936e3
commit 2b04108f93
+9 -2
View File
@@ -206,8 +206,15 @@ class TestRoleSessionRouter(unittest.TestCase):
class TestCheckMidMerge(unittest.TestCase): class TestCheckMidMerge(unittest.TestCase):
def test_skip_scan_walk_root_skips_sibling_worktrees_only(self): def test_skip_scan_walk_root_skips_sibling_worktrees_only(self):
worktree_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Hermetic <main>/branches/<worktree> layout (#283): deriving these
main_root = os.path.dirname(os.path.dirname(worktree_root)) # paths from __file__ made the test pass only when the suite ran from
# a branches/ worktree, because skip_python_scan_walk_root skips a
# branches/ walk root only when <project_root>/branches exists.
with tempfile.TemporaryDirectory() as tmp:
main_root = os.path.join(tmp, "main")
worktree_root = os.path.join(main_root, "branches", "fix-issue-1")
os.makedirs(os.path.join(worktree_root, "tests"))
self.assertFalse( self.assertFalse(
role_session_router.skip_python_scan_walk_root( role_session_router.skip_python_scan_walk_root(
main_root, main_root main_root, main_root