Add BATS test suite for wt toolkit#12
Merged
guodong-sq merged 1 commit intomainfrom Feb 9, 2026
Merged
Conversation
Add comprehensive test coverage for all wt scripts using BATS
(Bash Automated Testing System) with bats-assert and bats-support
as git submodules.
Test structure:
- test/unit/ — library function tests (wt-common, wt-context, wt-context-setup)
- test/integration/ — per-command tests (wt-add, wt-cd, wt-context, wt-list,
wt-metadata-export, wt-metadata-import, wt-remove, wt-switch)
- test/e2e/ — full workflow tests (lifecycle, multi-worktree, context switching)
- test/test_helper/ — shared setup, teardown, and assertion helpers
- test/README.md — test architecture docs and guide for adding new tests
Source fixes applied during test development:
- wt-list: add usage() function, -h/--help flag, use pwd -P for consistent
path comparison with git worktree list output
- wt-common: refactor config loading to source wt-context library directly
instead of custom parsing; use pwd -P in wt_get_linked_worktree for macOS
symlink consistency (/var -> /private/var)
- wt-add: improve install_bazel_symlinks_for_worktree doc comment
Also update CONTRIBUTING.md to reference the new test suite.
3418b34 to
58ed518
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
Initial attempt to add test coverage for the wt worktree toolkit using BATS (Bash Automated Testing System).
This PR adds 167 tests across three layers:
Unit tests (test/unit/) - Direct function-level tests for library code (wt-common, wt-context, wt-context-setup). Tests output helpers, git helpers, path expansion, metadata detection, context CRUD operations, and config loading.
Integration tests (test/integration/) - Per-command tests for each bin/wt-* script (wt-add, wt-cd, wt-context, wt-list, wt-metadata-export, wt-metadata-import, wt-remove, wt-switch). Each test creates isolated git repos in temp directories and validates real git operations, file system state, symlink behavior, error handling, and safety checks.
E2E tests (test/e2e/) - Full workflow tests covering complete worktree lifecycle (create, switch, work, remove), multi-worktree management, new branch creation with -b, context switching across repositories, dirty worktree handling, and symlink consistency across repeated operations.
Test infrastructure
Source fixes discovered during testing
Test plan