summaryrefslogtreecommitdiff
path: root/tests/claude-code/test-sdd-workspace.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/claude-code/test-sdd-workspace.sh')
-rwxr-xr-xtests/claude-code/test-sdd-workspace.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/claude-code/test-sdd-workspace.sh b/tests/claude-code/test-sdd-workspace.sh
index 2e8c227..16cf50d 100755
--- a/tests/claude-code/test-sdd-workspace.sh
+++ b/tests/claude-code/test-sdd-workspace.sh
@@ -17,6 +17,16 @@ fail() {
FAILURES=$((FAILURES + 1))
}
+# Push a path through the same `cd ... && pwd` normalization that
+# sdd-workspace's own printed output goes through, so both sides of a
+# string comparison are guaranteed to be spelled identically. On Windows
+# Git Bash/MSYS, `git rev-parse --show-toplevel` (Windows-style,
+# C:/Users/...) and `cd ... && pwd` (MSYS-style, /c/Users/...) can print
+# different spellings of the identical physical directory; on Linux/macOS
+# this is a no-op since the two already agree (module the resolved-symlink
+# /var -> /private/var case handled by the mktemp comment above).
+physical_path() { (cd "$1" && pwd); }
+
cleanup() {
if [[ -n "$TEST_ROOT" && -d "$TEST_ROOT" ]]; then
rm -rf "$TEST_ROOT"
@@ -35,6 +45,7 @@ main() {
git init -q -b main "$TEST_ROOT/repo"
local repo
repo="$(cd "$TEST_ROOT/repo" && git rev-parse --show-toplevel)"
+ repo="$(physical_path "$repo")"
cat > "$repo/plan-a.md" <<'PLAN'
# Plan A
@@ -194,6 +205,7 @@ PLAN
( cd "$repo" && git worktree add -q "$wt" -b wt-feature )
local wt_root wt_dir
wt_root="$(cd "$wt" && git rev-parse --show-toplevel)"
+ wt_root="$(physical_path "$wt_root")"
wt_dir="$(cd "$wt" && "$SDD_SCRIPTS/sdd-workspace" plan-a.md)"
if [[ "$wt_dir" == "$wt_root/.superpowers/sdd/plan-a" && "$wt_dir" != "$dir_a" ]]; then
pass "linked worktree resolves its own distinct workspace"
@@ -350,6 +362,24 @@ PLAN
echo " marker: $(cat "$dir_out/plan-path" 2>/dev/null)"
fi
+ # --- A repo's own committed .superpowers/sdd/.gitignore is left alone ---
+ git init -q -b main "$TEST_ROOT/own-ignore"
+ local own own_ignore
+ own="$(cd "$TEST_ROOT/own-ignore" && git rev-parse --show-toplevel)"
+ own_ignore=$'*\n!.gitignore\n!*/\n!*/progress.md'
+ mkdir -p "$own/.superpowers/sdd"
+ printf '%s\n' "$own_ignore" > "$own/.superpowers/sdd/.gitignore"
+ printf '# Plan\n\n## Task 1: One\n\nOne.\n' > "$own/plan.md"
+ (cd "$own" && git add -A && git -c user.name=t -c user.email=t@t commit -qm init)
+ (cd "$own" && "$SDD_SCRIPTS/sdd-workspace" plan.md >/dev/null)
+ if [[ "$(cat "$own/.superpowers/sdd/.gitignore")" == "$own_ignore" \
+ && -z "$(cd "$own" && git status --porcelain -- .superpowers/sdd/.gitignore)" ]]; then
+ pass "an existing .superpowers/sdd/.gitignore is not overwritten"
+ else
+ fail "an existing .superpowers/sdd/.gitignore is not overwritten"
+ echo " now: $(cat "$own/.superpowers/sdd/.gitignore")"
+ fi
+
echo ""
if [[ "$FAILURES" -ne 0 ]]; then
echo "FAILED: $FAILURES assertion(s)."