diff options
Diffstat (limited to 'tests/claude-code')
| -rwxr-xr-x | tests/claude-code/test-executing-plans-scripts.sh | 27 | ||||
| -rwxr-xr-x | tests/claude-code/test-sdd-workspace.sh | 30 |
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/claude-code/test-executing-plans-scripts.sh b/tests/claude-code/test-executing-plans-scripts.sh index 994733b..e4e3904 100755 --- a/tests/claude-code/test-executing-plans-scripts.sh +++ b/tests/claude-code/test-executing-plans-scripts.sh @@ -33,6 +33,8 @@ main() { git init -q -b main "$TEST_ROOT/repo" local repo repo="$(cd "$TEST_ROOT/repo" && git rev-parse --show-toplevel)" + # Same spelling as the scripts print (pwd), not rev-parse's C:/... on Git Bash. + repo="$(cd "$repo" && pwd)" local git_id=(-c user.email=t@example.com -c user.name=t -c commit.gpgsign=false) cat > "$repo/plan.md" <<'PLAN' @@ -127,6 +129,31 @@ PLAN echo " got: $out" fi + # --- task-done: records a passing task whose test command prints nothing --- + # https://github.com/obra/superpowers/issues/2385 -- under `set -euo + # pipefail`, the ledger's `grep -v '^[[:space:]]*$' log | tail -n 1` + # exits 1 on an empty/blank log, which used to abort the whole script + # (silently, no ledger line) even though the test command itself passed. + ( cd "$repo" && echo y > work2.txt && git add work2.txt && git "${git_id[@]}" commit -qm "task 2" ) + local head2 + head2="$(cd "$repo" && git rev-parse HEAD)" + rc=0 + out="$(cd "$repo" && "$EP_SCRIPTS/task-done" plan.md 2 "$head" -- true 2>&1)" || rc=$? + if [[ "$rc" -eq 0 ]]; then + pass "task-done exits 0 when a passing test command prints nothing" + else + fail "task-done exits 0 when a passing test command prints nothing (got rc=$rc)" + echo " got: $out" + fi + local expected2="Task 2: complete (commits ${head:0:7}..${head2:0:7}, tests: true → (no output))" + if [[ -f "$ledger" ]] && grep -qF "$expected2" "$ledger"; then + pass "task-done records a passing task that printed no output" + else + fail "task-done records a passing task that printed no output" + echo " expected: $expected2" + echo " ledger:"; sed 's/^/ /' "$ledger" 2>/dev/null || echo " (missing)" + fi + echo if [[ "$FAILURES" -eq 0 ]]; then echo "PASS" 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)." |
