blob: 80ac8dd86696f041e18b500f4fc25566c2ce20e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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"
}
|