test-worktree-path-policy.sh 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #!/usr/bin/env bash
  2. # Regression check: Superpowers should not route new worktrees through the old
  3. # global worktree directory.
  4. set -euo pipefail
  5. SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
  6. REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
  7. USING_SKILL="$REPO_ROOT/skills/using-git-worktrees/SKILL.md"
  8. FINISHING_SKILL="$REPO_ROOT/skills/finishing-a-development-branch/SKILL.md"
  9. ROTOTILL_SPEC="$REPO_ROOT/docs/superpowers/specs/2026-04-06-worktree-rototill-design.md"
  10. ROTOTILL_PLAN="$REPO_ROOT/docs/superpowers/plans/2026-04-06-worktree-rototill.md"
  11. failures=0
  12. assert_contains() {
  13. local file="$1"
  14. local pattern="$2"
  15. local label="$3"
  16. if grep -Fq "$pattern" "$file"; then
  17. echo " [PASS] $label"
  18. else
  19. echo " [FAIL] $label"
  20. echo " Expected to find: $pattern"
  21. echo " In file: $file"
  22. failures=$((failures + 1))
  23. fi
  24. }
  25. assert_not_contains() {
  26. local file="$1"
  27. local pattern="$2"
  28. local label="$3"
  29. if grep -Fq "$pattern" "$file"; then
  30. echo " [FAIL] $label"
  31. echo " Did not expect to find: $pattern"
  32. echo " In file: $file"
  33. failures=$((failures + 1))
  34. else
  35. echo " [PASS] $label"
  36. fi
  37. }
  38. echo "=== Worktree Path Policy Test ==="
  39. echo ""
  40. assert_not_contains "$USING_SKILL" "~/.config/superpowers/worktrees" "using-git-worktrees does not mention old global path"
  41. assert_not_contains "$USING_SKILL" "global legacy" "using-git-worktrees does not use unclear global legacy shorthand"
  42. assert_not_contains "$USING_SKILL" "Global path" "using-git-worktrees has no global path quick-reference row"
  43. assert_contains "$USING_SKILL" 'default to `.worktrees/` at the project root' "using-git-worktrees defaults new manual worktrees to .worktrees/"
  44. assert_not_contains "$FINISHING_SKILL" "~/.config/superpowers/worktrees" "finishing-a-development-branch does not treat old global path as owned"
  45. assert_contains "$FINISHING_SKILL" '`.worktrees/` or `worktrees/`' "finishing-a-development-branch keeps project-local cleanup ownership"
  46. assert_not_contains "$ROTOTILL_SPEC" "~/.config/superpowers/worktrees" "rototill spec does not preserve old global path policy"
  47. assert_not_contains "$ROTOTILL_PLAN" "~/.config/superpowers/worktrees" "rototill plan does not preserve old global path policy"
  48. assert_not_contains "$ROTOTILL_PLAN" "legacy path compat" "rototill plan does not advertise legacy path compatibility"
  49. echo ""
  50. if [ "$failures" -gt 0 ]; then
  51. echo "STATUS: FAILED ($failures failures)"
  52. exit 1
  53. fi
  54. echo "STATUS: PASSED"