Sibling-worktree skip test fails outside branches/ worktree layout (location-dependent) #283

Closed
opened 2026-07-06 23:17:15 -05:00 by jcwalker3 · 0 comments
Owner

Problem

tests/test_role_session_router.py::TestCheckMidMerge::test_skip_scan_walk_root_skips_sibling_worktrees_only fails on a clean master checkout:

AssertionError: False is not true

Root cause

The test derives its fixture paths from its own file location:

worktree_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
main_root = os.path.dirname(os.path.dirname(worktree_root))

and then asserts skip_python_scan_walk_root(main_root, main_root/branches/fix-issue-1) is True. But skip_python_scan_walk_root only skips a branches/ walk root when <project_root>/branches exists on disk (os.path.isdir(nested)).

So the assertion holds only when the repo checkout itself sits at <main>/branches/<slug> (the branch-worktree layout, where main_root resolves to the orchestration checkout that really has a branches/ dir). Run the suite from the main checkout or any plain clone and main_root resolves two directories above the repo, branches/ does not exist there, and the test fails.

Reproduced on clean master (d6f4f93) in a plain clone; also fails from the primary checkout.

Fix

Make the test hermetic: build the <main>/branches/<worktree> layout in a tempfile.TemporaryDirectory() and assert against those paths instead of deriving from __file__. Preserves all four behavioural assertions (orchestration root scanned, sibling worktrees skipped, worktree-as-project-root scanned including subdirs).

Acceptance

  • Test passes from a plain clone, the main checkout, and a branches/ worktree alike.
  • All four original assertions preserved.
  • No production code change to skip_python_scan_walk_root.
## Problem `tests/test_role_session_router.py::TestCheckMidMerge::test_skip_scan_walk_root_skips_sibling_worktrees_only` fails on a clean `master` checkout: ```text AssertionError: False is not true ``` ## Root cause The test derives its fixture paths from its own file location: ```python worktree_root = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) main_root = os.path.dirname(os.path.dirname(worktree_root)) ``` and then asserts `skip_python_scan_walk_root(main_root, main_root/branches/fix-issue-1)` is `True`. But `skip_python_scan_walk_root` only skips a `branches/` walk root when `<project_root>/branches` **exists on disk** (`os.path.isdir(nested)`). So the assertion holds only when the repo checkout itself sits at `<main>/branches/<slug>` (the branch-worktree layout, where `main_root` resolves to the orchestration checkout that really has a `branches/` dir). Run the suite from the main checkout or any plain clone and `main_root` resolves two directories above the repo, `branches/` does not exist there, and the test fails. Reproduced on clean `master` (d6f4f93) in a plain clone; also fails from the primary checkout. ## Fix Make the test hermetic: build the `<main>/branches/<worktree>` layout in a `tempfile.TemporaryDirectory()` and assert against those paths instead of deriving from `__file__`. Preserves all four behavioural assertions (orchestration root scanned, sibling worktrees skipped, worktree-as-project-root scanned including subdirs). ## Acceptance - Test passes from a plain clone, the main checkout, and a `branches/` worktree alike. - All four original assertions preserved. - No production code change to `skip_python_scan_walk_root`.
jcwalker3 added the status:in-progress label 2026-07-06 23:17:31 -05:00
sysadmin removed the status:in-progress label 2026-07-07 02:08:40 -05:00
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Scaled-Tech-Consulting/Gitea-Tools#283