aboutsummaryrefslogtreecommitdiff
path: root/scripts/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-11 11:32:40 -0500
committerCraig Jennings <c@cjennings.net>2026-06-11 11:32:40 -0500
commitd576fc217ba304b48dfb1c54b92bc1849397fd9b (patch)
tree83c38f109409eccb524cdf5fe1ee37e91b5dc60d /scripts/tests
parent7095d622ab6e295143d1306bdb5c8ecd85cf0745 (diff)
downloadrulesets-d576fc217ba304b48dfb1c54b92bc1849397fd9b.tar.gz
rulesets-d576fc217ba304b48dfb1c54b92bc1849397fd9b.zip
fix(install): link default hooks in make install
session-clear-resume.sh shipped 2026-06-02 with its settings.json entry, but make install didn't cover hooks and nothing re-ran install-hooks, so the symlink only existed on machines that had linked it by hand. Everywhere else the hook errored silently on every /clear. make install now links DEFAULT_HOOKS alongside skills, rules, config, and bin scripts, so the startup workflow's install step propagates new hooks machine-wide. Opt-in hooks stay manual. scripts/tests/install-hooks-link.bats covers the new section. The SessionStart-on-clear todo task closes with this: the hook feature already existed, and the gap was distribution.
Diffstat (limited to 'scripts/tests')
-rw-r--r--scripts/tests/install-hooks-link.bats56
1 files changed, 56 insertions, 0 deletions
diff --git a/scripts/tests/install-hooks-link.bats b/scripts/tests/install-hooks-link.bats
new file mode 100644
index 0000000..80ac8dd
--- /dev/null
+++ b/scripts/tests/install-hooks-link.bats
@@ -0,0 +1,56 @@
+#!/usr/bin/env bats
+# make install must link default hooks into HOOKS_DIR. The gap this guards:
+# install-hooks was a separate target nobody re-ran, so a hook added to the
+# repo (session-clear-resume.sh, 2026-06-02) reached settings.json on every
+# machine via the tracked symlink but its ~/.claude/hooks/ link never landed,
+# and the hook errored silently on every /clear until a manual install.
+
+setup() {
+ REPO_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"
+ TMPHOME="$(mktemp -d)"
+}
+
+teardown() {
+ rm -rf "$TMPHOME"
+}
+
+run_install() {
+ make -C "$REPO_ROOT" install \
+ SKILLS_DIR="$TMPHOME/skills" \
+ RULES_DIR="$TMPHOME/rules" \
+ HOOKS_DIR="$TMPHOME/hooks" \
+ CLAUDE_DIR="$TMPHOME/claude" \
+ LOCAL_BIN="$TMPHOME/bin"
+}
+
+@test "install links default hooks into HOOKS_DIR" {
+ run run_install
+ [ "$status" -eq 0 ]
+ [ -L "$TMPHOME/hooks/session-clear-resume.sh" ]
+ [ -L "$TMPHOME/hooks/precompact-priorities.sh" ]
+}
+
+@test "install does not link opt-in hooks" {
+ run run_install
+ [ "$status" -eq 0 ]
+ [ ! -e "$TMPHOME/hooks/destructive-bash-confirm.py" ]
+}
+
+@test "install is idempotent on hooks (second run skips, link survives)" {
+ run run_install
+ [ "$status" -eq 0 ]
+ run run_install
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"skip session-clear-resume.sh (already linked)"* ]]
+ [ -L "$TMPHOME/hooks/session-clear-resume.sh" ]
+}
+
+@test "install warns on a non-symlink collision and leaves the file alone" {
+ mkdir -p "$TMPHOME/hooks"
+ echo "real file" > "$TMPHOME/hooks/session-clear-resume.sh"
+ run run_install
+ [ "$status" -eq 0 ]
+ [[ "$output" == *"WARN session-clear-resume.sh exists and is not a symlink"* ]]
+ [ ! -L "$TMPHOME/hooks/session-clear-resume.sh" ]
+ grep -q "real file" "$TMPHOME/hooks/session-clear-resume.sh"
+}