test: split wt.bats into one file per command - #3
Open
stilliard wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR reorganizes the Bats test suite for wt by splitting the monolithic test/wt.bats into per-command test files, extracting shared setup/teardown helpers, and isolating --claude integration tests under a dedicated subdirectory. It also updates the README to reflect running the suite recursively.
Changes:
- Split
test/wt.batsinto separatetest/*.batsfiles (plustest/claude/*.batsfor--claudecoverage). - Extract shared
setup()/teardown()logic intotest/helpers.bashand load it per test file. - Update README test instructions to use
bats -r test.
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| test/wt.bats | Removed monolithic test file in favor of per-command files. |
| test/helpers.bash | New shared setup/teardown helper used by all Bats files. |
| test/resolve.bats | _wt_resolve tests moved into their own file. |
| test/cd.bats | _wt_cd tests moved into their own file. |
| test/ls.bats | Core wt ls / list/alias tests moved into their own file. |
| test/mk.bats | wt mk tests (including hooks and .worktreeinclude) moved into their own file. |
| test/rm.bats | wt rm tests (including hooks and ad-hoc hooks) moved into their own file. |
| test/prune.bats | wt prune tests moved into their own file. |
| test/merged.bats | Core wt merged tests moved into their own file (non---claude). |
| test/claude/ls.bats | wt ls --claude tests moved under test/claude/. |
| test/claude/merged.bats | wt merged --claude tests moved under test/claude/. |
| README.md | Updated test-running instructions to bats -r test. |
Suppressed comments (1)
test/claude/merged.bats:80
- The stub
jqwrapper uses an unquoted$(command -v jq)expansion, which can break if the resolved path contains whitespace (word-splitting). Quote the resolved path beforeexec.
cat > "$stubbin/jq" <<EOF
#!/usr/bin/env bash
exec $(command -v jq) "\$@"
EOF
chmod +x "$stubbin/jq"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
stilliard
force-pushed
the
test/split-per-command
branch
5 times, most recently
from
August 6, 2026 17:03
152e7b4 to
a4eef27
Compare
Splits the single 596-line test/wt.bats into test/<command>.bats (resolve, cd, ls, mk, rm, prune, merged, help), each with the shared setup/teardown pulled into test/helpers.bash and loaded via `load helpers`. --claude flag tests move to test/claude/<command>.bats (ls, merged) so Claude Code integration coverage stays grouped separately from each command's core behavior. No test content changed - same 53 tests, same assertions, just reorganized. Run with `bats -r test` (recursive) since tests now live in a subdirectory; README updated accordingly. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
- helpers.bash: fix misleading "bare repo" comment (it's a normal repo) - helpers.bash: locate wt.sh by walking up from BATS_TEST_DIRNAME instead of git rev-parse, so tests don't require a git checkout - quote $(command -v jq) in stub wrappers against paths with spaces - clean up leaked stub dir in the ls.bats missing-claude test Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
stilliard
force-pushed
the
test/split-per-command
branch
from
August 6, 2026 18:14
a4eef27 to
85e48d1
Compare
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.
Summary
Stacked on #2 (this PR targets that branch, not
main, since it splits out the--claudetests added there).test/wt.bats→ one file per command:test/resolve.bats,cd.bats,ls.bats,mk.bats,rm.bats,prune.bats,merged.bats,help.batssetup()/teardown()extracted totest/helpers.bash, loaded per-file withload helpers--claudeflag tests moved totest/claude/ls.batsandtest/claude/merged.bats, kept separate from each command's core behavior testsbats -r test(recursive, since tests now live in a subdirectory)Test plan
bats -r test— 53/53 passing (same count as before the split)🤖 Generated with Claude Code