Repository navigation
Fix test bugs and tidy test helpers - #45
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bugs fixed:
merges the branch into main while the rebase is stopped, and asserts the
"checked out in" warning and that the branch survives.
GIT_COMMON_DIR and sets GIT_CONFIG_GLOBAL and GIT_CEILING_DIRECTORIES, so
a run from a git hook cannot touch the host repo.
creates as directories, and checks the repo is clean first.
and failed when TMPDIR was inside a git repo. It now calls gittest.NewBare(t).
Cleanups:
Behavior and case count are unchanged (113 subtests before and after).
No production issues found.