Skip to content

test: split wt.bats into one file per command - #3

Open
stilliard wants to merge 2 commits into
mainfrom
test/split-per-command
Open

test: split wt.bats into one file per command#3
stilliard wants to merge 2 commits into
mainfrom
test/split-per-command

Conversation

@stilliard

Copy link
Copy Markdown
Owner

Summary

Stacked on #2 (this PR targets that branch, not main, since it splits out the --claude tests 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.bats
  • Shared setup()/teardown() extracted to test/helpers.bash, loaded per-file with load helpers
  • --claude flag tests moved to test/claude/ls.bats and test/claude/merged.bats, kept separate from each command's core behavior tests
  • No test content changed — same 53 tests, same assertions, just reorganized
  • README updated: bats -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

Copilot AI lite review requested due to automatic review settings August 6, 2026 14:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.bats into separate test/*.bats files (plus test/claude/*.bats for --claude coverage).
  • Extract shared setup() / teardown() logic into test/helpers.bash and 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 jq wrapper uses an unquoted $(command -v jq) expansion, which can break if the resolved path contains whitespace (word-splitting). Quote the resolved path before exec.
  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.

Comment thread test/helpers.bash Outdated
Comment thread test/helpers.bash Outdated
Comment thread test/claude/ls.bats
Comment thread test/claude/ls.bats
Comment thread test/claude/merged.bats
@stilliard
stilliard force-pushed the test/split-per-command branch 5 times, most recently from 152e7b4 to a4eef27 Compare August 6, 2026 17:03
@stilliard
stilliard changed the base branch from feat/merged-claude-integration to main August 6, 2026 18:12
stilliard and others added 2 commits August 6, 2026 19:12
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>
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.

2 participants