Skip to content

Fix test bugs and tidy test helpers - #45

Merged
arbourd merged 2 commits into
mainfrom
arbourd/test-review-sync
Nov 17, 2026
Merged

arbourd merged 2 commits into
mainfrom
arbourd/test-review-sync

Conversation

@arbourd

@arbourd arbourd commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

Bugs fixed:

  • The mid-rebase delete test passed without exercising the guard. It now
    merges the branch into main while the rebase is stopped, and asserts the
    "checked out in" warning and that the branch survives.
  • gittest isolation now clears GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE and
    GIT_COMMON_DIR and sets GIT_CONFIG_GLOBAL and GIT_CEILING_DIRECTORIES, so
    a run from a git hook cannot touch the host repo.
  • runSync closes its pipe if sync() panics instead of hanging the reader.
  • TestUpdateRef no longer update-refs a checked-out branch.
  • TestIsClean_OperationInProgress uses real directories for the markers git
    creates as directories, and checks the repo is clean first.
  • The other-worktree fast-forward test now asserts that main moved.
  • Rebase setup goes through stopRebase, which checks the rebase stopped.
  • TestIsGitDir_NotGitDir never called isolate, so it had no GIT_CEILING_DIRECTORIES
    and failed when TMPDIR was inside a git repo. It now calls gittest.NewBare(t).

Cleanups:

  • Reuse writeFile and pushFile instead of repeated inline sequences.
  • gittest.Chdir is gone; callers use t.Chdir.
  • TestLocalBranches uses slices.Sort and slices.Equal.
  • git commands in tests use exec.CommandContext(t.Context(), ...).

Behavior and case count are unchanged (113 subtests before and after).
No production issues found.

Bugs fixed:
- The mid-rebase delete test passed without exercising the guard. It now
  merges the branch into main while the rebase is stopped, and asserts the
  "checked out in" warning and that the branch survives.
- gittest isolation now clears GIT_DIR, GIT_WORK_TREE, GIT_INDEX_FILE and
  GIT_COMMON_DIR and sets GIT_CONFIG_GLOBAL and GIT_CEILING_DIRECTORIES, so
  a run from a git hook cannot touch the host repo.
- runSync closes its pipe if sync() panics instead of hanging the reader.
- TestUpdateRef no longer update-refs a checked-out branch.
- TestIsClean_OperationInProgress uses real directories for the markers git
  creates as directories, and checks the repo is clean first.
- The other-worktree fast-forward test now asserts that main moved.
- Rebase setup goes through stopRebase, which checks the rebase stopped.

Cleanups:
- Reuse writeFile and pushFile instead of repeated inline sequences.
- gittest.Chdir is gone; callers use t.Chdir.
- TestLocalBranches uses slices.Sort and slices.Equal.
- git commands in tests use exec.CommandContext(t.Context(), ...).

Behavior and case count are unchanged (113 subtests before and after).
No production issues found.
TestIsGitDir_NotGitDir never called isolate, so it had no
GIT_CEILING_DIRECTORIES and failed when TMPDIR was inside a git repo. It
now calls gittest.NewBare(t) first, as TestSync_NotAGitRepository does.

Clarify the isolation comment in gittest: the ceiling is the test's temp
root, and a test that never calls isolate gets none.
@arbourd
arbourd merged commit 8eabf5f into main Nov 17, 2026
10 checks passed
@arbourd
arbourd deleted the arbourd/test-review-sync branch November 17, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant