summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDrew Ritter <drew@primeradiant.com>2026-11-26 00:46:47 -0800
committerDrew Ritter <drew@primeradiant.com>2026-11-26 00:46:47 -0800
commit3d1bd8f963d1ef8ea1a01dc9b17729507c1ec6c4 (patch)
tree90d677c590c236b58c4c1b7ca5a525c5b5687f2f /tests
parentda0d65d55330d591b03b6b7d818dc7dd7746e4e1 (diff)
parentf27e901302c8294370ac77bfba148c7d72bc8b78 (diff)
Merge branch 'fix/wave1-run-hook-heredoc' into fix/wave1-public-docs-and-erratafix/wave1-public-docs-and-errata
Diffstat (limited to 'tests')
-rwxr-xr-xtests/hooks/test-session-start.sh31
1 files changed, 18 insertions, 13 deletions
diff --git a/tests/hooks/test-session-start.sh b/tests/hooks/test-session-start.sh
index 9332f42..79aefb7 100755
--- a/tests/hooks/test-session-start.sh
+++ b/tests/hooks/test-session-start.sh
@@ -352,15 +352,22 @@ if [[ -n "$posix_sh" ]]; then
CLAUDE_PLUGIN_ROOT="$REPO_ROOT" \
"$posix_sh" "$WRAPPER_UNDER_TEST" session-start
fi
+else
+ echo " [SKIP] run-hook.cmd/session-start sh-only tests: no non-bash/non-zsh POSIX sh found"
+fi
- # Adversarial escaping test under POSIX sh (backslashes, quotes, tabs, globs, CRLF)
- tricky_root="$TEST_ROOT/tricky-plugin"
- mkdir -p "$tricky_root/hooks" "$tricky_root/skills/using-superpowers"
- cp "$HOOK_UNDER_TEST" "$tricky_root/hooks/session-start"
- printf 'Line1: C:\\Users\\new\\tab"quote\\*?[foo]\\bar\r\nLine2:\twith\ttabs and ""quotes""\n\n' > "$tricky_root/skills/using-superpowers/SKILL.md"
- tricky_json="$(env -i PATH="" HOME="$(make_home sh-tricky)" CLAUDE_PLUGIN_ROOT="$tricky_root" \
- "$posix_sh" "$tricky_root/hooks/session-start")"
- if node -e '
+# Adversarial escaping test (backslashes, quotes, tabs, globs, CRLF) under
+# every shell the wrapper can pick. bash gets CR through printf -v, the
+# others through a command substitution.
+tricky_root="$TEST_ROOT/tricky-plugin"
+mkdir -p "$tricky_root/hooks" "$tricky_root/skills/using-superpowers"
+cp "$HOOK_UNDER_TEST" "$tricky_root/hooks/session-start"
+printf 'Line1: C:\\Users\\new\\tab"quote\\*?[foo]\\bar\r\nLine2:\twith\ttabs and ""quotes""\n\n' > "$tricky_root/skills/using-superpowers/SKILL.md"
+for tricky_sh in ${posix_sh:+"$posix_sh"} "$BASH" ${zsh_bin:+"$zsh_bin"}; do
+ tricky_rc=0
+ tricky_json="$(env -i PATH="" HOME="$(make_home "tricky-${tricky_sh##*/}")" CLAUDE_PLUGIN_ROOT="$tricky_root" \
+ "$tricky_sh" "$tricky_root/hooks/session-start")" || tricky_rc=$?
+ if [[ "$tricky_rc" -eq 0 ]] && node -e '
const fs = require("fs");
const raw = fs.readFileSync(process.argv[1], "utf8").replace(/\n+$/, "");
const parsed = JSON.parse(process.argv[2]);
@@ -370,13 +377,11 @@ if [[ -n "$posix_sh" ]]; then
process.exit(1);
}
' "$tricky_root/skills/using-superpowers/SKILL.md" "$tricky_json"; then
- pass "POSIX sh (${posix_sh##*/}) round-trips backslashes, quotes, tabs, globs, and CRLF in JSON"
+ pass "${tricky_sh##*/} round-trips backslashes, quotes, tabs, globs, and CRLF in JSON"
else
- fail "POSIX sh (${posix_sh##*/}) round-trips backslashes, quotes, tabs, globs, and CRLF in JSON"
+ fail "${tricky_sh##*/} round-trips backslashes, quotes, tabs, globs, and CRLF in JSON (rc=$tricky_rc)"
fi
-else
- echo " [SKIP] run-hook.cmd/session-start sh-only tests: no non-bash/non-zsh POSIX sh found"
-fi
+done
# Run by bare filename from inside hooks/ ($0 has no slash), the plugin root
# must still resolve.