blob: 130212d2953d1b10357f50f21f157ee5f1c445cc (
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
|
#!/usr/bin/env bats
#
# Coverage tests for scripts/lint.sh.
#
# lint.sh sweeps scripts/*.sh, languages/*/claude/hooks/*.sh, and
# languages/*/githooks/* through check_hook (shebang present, executable bit
# set). It never touched claude-templates/bin/ — the four scripts `make install`
# symlinks into ~/.local/bin, so the most exposed shell in the repo was the only
# shell with no gate over it (found 2026-07-24).
#
# These tests pin the coverage itself rather than the current cleanliness: they
# plant a deliberately broken file in each swept location and assert lint.sh
# complains. A location that stops being swept fails here.
REPO_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/../.." && pwd)"
LINT="$REPO_ROOT/scripts/lint.sh"
teardown() {
[ -n "${PLANTED:-}" ] && rm -f "$PLANTED"
PLANTED=""
}
@test "lint: a bin/ script missing its shebang is flagged" {
PLANTED="$REPO_ROOT/claude-templates/bin/zz-test-noshebang"
printf 'echo hi\n' > "$PLANTED"
chmod +x "$PLANTED"
run bash "$LINT"
[[ "$output" == *"zz-test-noshebang"* ]] || {
echo "lint.sh did not report the planted bin/ script — that path is unswept"
echo "$output"
return 1
}
}
@test "lint: a bin/ script that is not executable is flagged" {
PLANTED="$REPO_ROOT/claude-templates/bin/zz-test-noexec"
printf '#!/usr/bin/env bash\necho hi\n' > "$PLANTED"
chmod -x "$PLANTED"
run bash "$LINT"
[[ "$output" == *"zz-test-noexec"* ]]
}
@test "lint: the existing scripts/ sweep still works (guards the regression)" {
PLANTED="$REPO_ROOT/scripts/zz-test-noshebang.sh"
printf 'echo hi\n' > "$PLANTED"
chmod +x "$PLANTED"
run bash "$LINT"
[[ "$output" == *"zz-test-noshebang.sh"* ]]
}
@test "lint: the real tree passes (no planted file)" {
run bash "$LINT"
[ "$status" -eq 0 ]
}
|