Skip to content

Commit e886bf0

Browse files
authored
Fix the unit test that silently skipped the re-parenting path (#57)
When the simulated squash cherry-pick in test_update_pr_stack.sh lands in the same second as the original feature1 commit, it reproduces its sha exactly; the script then sees the child as already up to date and the test passes without exercising git-merge-onto at all. When the timing crosses a second boundary, the run reaches git-merge-onto, which refuses to start because the test's own tee output sits untracked inside the test repo. So since #56 the test either tested nothing or flaked. Cherry-pick with -x so the sha always differs, and write the run log outside the repo. Found while rebasing #52.
1 parent 718074f commit e886bf0

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

tests/test_update_pr_stack.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,12 @@ log_cmd git add file.txt
5858
log_cmd git commit -m "Add feature 3"
5959
simulate_push feature3
6060

61-
# Simulate a squash merge of feature1 into main by cherry-picking
61+
# Simulate a squash merge of feature1 into main by cherry-picking. -x changes
62+
# the commit message: a plain cherry-pick landing in the same second as the
63+
# original commit reproduces feature1's sha exactly, and the script then skips
64+
# the whole re-parenting as already done, silently testing nothing.
6265
log_cmd git checkout main
63-
log_cmd git cherry-pick "$FEATURE1_COMMIT" # Apply the changes from feature1's commit
66+
log_cmd git cherry-pick -x "$FEATURE1_COMMIT"
6467
# The cherry-pick creates a *new* commit on main, simulating the squash merge result
6568
SQUASH_COMMIT=$(log_cmd git rev-parse HEAD) # Get the hash of the new commit on main
6669
simulate_push main # Update origin/main to include the squash commit
@@ -72,7 +75,8 @@ echo "Simulated Squash commit (via cherry-pick): $SQUASH_COMMIT"
7275
echo "Running update-pr-stack.sh..."
7376
# The update script sources command_utils.sh itself
7477
# Capture stdout+stderr interleaved so command ordering can be asserted.
75-
RUN_LOG="$TEST_REPO/update_run.log"
78+
# Outside the test repo: an untracked file makes git-merge-onto refuse to run.
79+
RUN_LOG=$(mktemp)
7680
run_update_pr_stack() {
7781
log_cmd \
7882
env \

0 commit comments

Comments
 (0)