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:
@@ -206,28 +206,35 @@ class TestRoleSessionRouter(unittest.TestCase):
|
||||
|
||||
class TestCheckMidMerge(unittest.TestCase):
|
||||
def test_skip_scan_walk_root_skips_sibling_worktrees_only(self):
|
||||
worktree_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
main_root = os.path.dirname(os.path.dirname(worktree_root))
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
main_root, main_root
|
||||
# Hermetic <main>/branches/<worktree> layout (#283): deriving these
|
||||
# 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(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
main_root, main_root
|
||||
)
|
||||
)
|
||||
)
|
||||
self.assertTrue(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
main_root, os.path.join(main_root, "branches", "fix-issue-1")
|
||||
self.assertTrue(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
main_root, os.path.join(main_root, "branches", "fix-issue-1")
|
||||
)
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
worktree_root, worktree_root
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
worktree_root, worktree_root
|
||||
)
|
||||
)
|
||||
)
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
worktree_root, os.path.join(worktree_root, "tests")
|
||||
self.assertFalse(
|
||||
role_session_router.skip_python_scan_walk_root(
|
||||
worktree_root, os.path.join(worktree_root, "tests")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def test_decorative_equals_banner_is_not_mid_merge(self):
|
||||
self.assertFalse(role_session_router.check_mid_merge())
|
||||
|
||||
Reference in New Issue
Block a user