mirror of
https://github.com/obra/superpowers.git
synced 2026-06-11 13:19:05 +08:00
Compare commits
1 Commits
drew/sup-3
...
codex/shel
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb6bdf9dd3 |
@@ -97,7 +97,7 @@ if [[ -f "$PID_FILE" ]]; then
|
|||||||
rm -f "$PID_FILE"
|
rm -f "$PID_FILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR" || exit
|
||||||
|
|
||||||
# Resolve the harness PID (grandparent of this script).
|
# Resolve the harness PID (grandparent of this script).
|
||||||
# $PPID is the ephemeral shell the harness spawned to run us — it dies
|
# $PPID is the ephemeral shell the harness spawned to run us — it dies
|
||||||
@@ -135,7 +135,7 @@ disown "$SERVER_PID" 2>/dev/null
|
|||||||
echo "$SERVER_PID" > "$PID_FILE"
|
echo "$SERVER_PID" > "$PID_FILE"
|
||||||
|
|
||||||
# Wait for server-started message (check log file)
|
# Wait for server-started message (check log file)
|
||||||
for i in {1..50}; do
|
for _ in {1..50}; do
|
||||||
if grep -q "server-started" "$LOG_FILE" 2>/dev/null; then
|
if grep -q "server-started" "$LOG_FILE" 2>/dev/null; then
|
||||||
# Verify server is still alive after a short window (catches process reapers)
|
# Verify server is still alive after a short window (catches process reapers)
|
||||||
alive="true"
|
alive="true"
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ if [[ -f "$PID_FILE" ]]; then
|
|||||||
kill "$pid" 2>/dev/null || true
|
kill "$pid" 2>/dev/null || true
|
||||||
|
|
||||||
# Wait for graceful shutdown (up to ~2s)
|
# Wait for graceful shutdown (up to ~2s)
|
||||||
for i in {1..20}; do
|
for _ in {1..20}; do
|
||||||
if ! kill -0 "$pid" 2>/dev/null; then
|
if ! kill -0 "$pid" 2>/dev/null; then
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ run_claude() {
|
|||||||
local prompt="$1"
|
local prompt="$1"
|
||||||
local timeout="${2:-60}"
|
local timeout="${2:-60}"
|
||||||
local allowed_tools="${3:-}"
|
local allowed_tools="${3:-}"
|
||||||
local output_file=$(mktemp)
|
local output_file
|
||||||
|
output_file="$(mktemp)"
|
||||||
|
|
||||||
# Build command as an argv array so timeout wraps claude directly.
|
# Build command as an argv array so timeout wraps claude directly.
|
||||||
local cmd=(claude -p "$prompt")
|
local cmd=(claude -p "$prompt")
|
||||||
@@ -74,7 +75,8 @@ assert_count() {
|
|||||||
local expected="$3"
|
local expected="$3"
|
||||||
local test_name="${4:-test}"
|
local test_name="${4:-test}"
|
||||||
|
|
||||||
local actual=$(echo "$output" | grep -c "$pattern" || echo "0")
|
local actual
|
||||||
|
actual="$(echo "$output" | grep -c "$pattern" || true)"
|
||||||
|
|
||||||
if [ "$actual" -eq "$expected" ]; then
|
if [ "$actual" -eq "$expected" ]; then
|
||||||
echo " [PASS] $test_name (found $actual instances)"
|
echo " [PASS] $test_name (found $actual instances)"
|
||||||
@@ -98,8 +100,10 @@ assert_order() {
|
|||||||
local test_name="${4:-test}"
|
local test_name="${4:-test}"
|
||||||
|
|
||||||
# Get line numbers where patterns appear
|
# Get line numbers where patterns appear
|
||||||
local line_a=$(echo "$output" | grep -n "$pattern_a" | head -1 | cut -d: -f1)
|
local line_a
|
||||||
local line_b=$(echo "$output" | grep -n "$pattern_b" | head -1 | cut -d: -f1)
|
local line_b
|
||||||
|
line_a="$(echo "$output" | grep -n "$pattern_a" | head -1 | cut -d: -f1 || true)"
|
||||||
|
line_b="$(echo "$output" | grep -n "$pattern_b" | head -1 | cut -d: -f1 || true)"
|
||||||
|
|
||||||
if [ -z "$line_a" ]; then
|
if [ -z "$line_a" ]; then
|
||||||
echo " [FAIL] $test_name: pattern A not found: $pattern_a"
|
echo " [FAIL] $test_name: pattern A not found: $pattern_a"
|
||||||
@@ -125,7 +129,8 @@ assert_order() {
|
|||||||
# Create a temporary test project directory
|
# Create a temporary test project directory
|
||||||
# Usage: test_project=$(create_test_project)
|
# Usage: test_project=$(create_test_project)
|
||||||
create_test_project() {
|
create_test_project() {
|
||||||
local test_dir=$(mktemp -d)
|
local test_dir
|
||||||
|
test_dir="$(mktemp -d)"
|
||||||
echo "$test_dir"
|
echo "$test_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ TEST_PROJECT=$(create_test_project)
|
|||||||
echo "Test project: $TEST_PROJECT"
|
echo "Test project: $TEST_PROJECT"
|
||||||
|
|
||||||
# Trap to cleanup
|
# Trap to cleanup
|
||||||
trap "cleanup_test_project $TEST_PROJECT" EXIT
|
cleanup_integration_test_project() {
|
||||||
|
cleanup_test_project "$TEST_PROJECT"
|
||||||
|
}
|
||||||
|
trap cleanup_integration_test_project EXIT
|
||||||
|
|
||||||
# Set up minimal Node.js project
|
# Set up minimal Node.js project
|
||||||
cd "$TEST_PROJECT"
|
cd "$TEST_PROJECT"
|
||||||
@@ -164,12 +167,19 @@ PLUGIN_DIR=$(cd "$SCRIPT_DIR/../.." && pwd)
|
|||||||
# other concurrent claude sessions.
|
# other concurrent claude sessions.
|
||||||
echo "Running Claude (plugin-dir: $PLUGIN_DIR, cwd: $TEST_PROJECT)..."
|
echo "Running Claude (plugin-dir: $PLUGIN_DIR, cwd: $TEST_PROJECT)..."
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
cd "$TEST_PROJECT" && timeout 1800 claude -p "$PROMPT" --plugin-dir "$PLUGIN_DIR" --allowed-tools=all --permission-mode bypassPermissions 2>&1 | tee "$OUTPUT_FILE" || {
|
set +e
|
||||||
|
(
|
||||||
|
cd "$TEST_PROJECT" &&
|
||||||
|
timeout 1800 claude -p "$PROMPT" --plugin-dir "$PLUGIN_DIR" --allowed-tools=all --permission-mode bypassPermissions
|
||||||
|
) 2>&1 | tee "$OUTPUT_FILE"
|
||||||
|
execution_status=$?
|
||||||
|
set -e
|
||||||
|
if [[ "$execution_status" -ne 0 ]]; then
|
||||||
echo ""
|
echo ""
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
echo "EXECUTION FAILED (exit code: $?)"
|
echo "EXECUTION FAILED (exit code: $execution_status)"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
fi
|
||||||
echo "================================================================================"
|
echo "================================================================================"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
@@ -47,16 +47,20 @@ assert_not_contains() {
|
|||||||
echo "=== Worktree Path Policy Test ==="
|
echo "=== Worktree Path Policy Test ==="
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
assert_not_contains "$USING_SKILL" "~/.config/superpowers/worktrees" "using-git-worktrees does not mention old global path"
|
# Intentionally search for the literal legacy path, not the current user's home.
|
||||||
|
# shellcheck disable=SC2088
|
||||||
|
legacy_global_worktree_path="~/.config/superpowers/worktrees"
|
||||||
|
|
||||||
|
assert_not_contains "$USING_SKILL" "$legacy_global_worktree_path" "using-git-worktrees does not mention old global path"
|
||||||
assert_not_contains "$USING_SKILL" "global legacy" "using-git-worktrees does not use unclear global legacy shorthand"
|
assert_not_contains "$USING_SKILL" "global legacy" "using-git-worktrees does not use unclear global legacy shorthand"
|
||||||
assert_not_contains "$USING_SKILL" "Global path" "using-git-worktrees has no global path quick-reference row"
|
assert_not_contains "$USING_SKILL" "Global path" "using-git-worktrees has no global path quick-reference row"
|
||||||
assert_contains "$USING_SKILL" 'default to `.worktrees/` at the project root' "using-git-worktrees defaults new manual worktrees to .worktrees/"
|
assert_contains "$USING_SKILL" 'default to `.worktrees/` at the project root' "using-git-worktrees defaults new manual worktrees to .worktrees/"
|
||||||
|
|
||||||
assert_not_contains "$FINISHING_SKILL" "~/.config/superpowers/worktrees" "finishing-a-development-branch does not treat old global path as owned"
|
assert_not_contains "$FINISHING_SKILL" "$legacy_global_worktree_path" "finishing-a-development-branch does not treat old global path as owned"
|
||||||
assert_contains "$FINISHING_SKILL" '`.worktrees/` or `worktrees/`' "finishing-a-development-branch keeps project-local cleanup ownership"
|
assert_contains "$FINISHING_SKILL" '`.worktrees/` or `worktrees/`' "finishing-a-development-branch keeps project-local cleanup ownership"
|
||||||
|
|
||||||
assert_not_contains "$ROTOTILL_SPEC" "~/.config/superpowers/worktrees" "rototill spec does not preserve old global path policy"
|
assert_not_contains "$ROTOTILL_SPEC" "$legacy_global_worktree_path" "rototill spec does not preserve old global path policy"
|
||||||
assert_not_contains "$ROTOTILL_PLAN" "~/.config/superpowers/worktrees" "rototill plan does not preserve old global path policy"
|
assert_not_contains "$ROTOTILL_PLAN" "$legacy_global_worktree_path" "rototill plan does not preserve old global path policy"
|
||||||
assert_not_contains "$ROTOTILL_PLAN" "legacy path compat" "rototill plan does not advertise legacy path compatibility"
|
assert_not_contains "$ROTOTILL_PLAN" "legacy path compat" "rototill plan does not advertise legacy path compatibility"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user