Files
Holocron/tests/test-plugin-content-consumer-neutral.sh
T
Defame1297andClaude Opus 5.5 75ec543b4b test(plugins): guard the consumer-neutral test's array expansion
test-vale-wrap's bash 3.2 scan flags a bare "${arr[@]}" expansion under
set -u. Use the guarded form the repo's other scripts use.

Refs: #177

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014uGZTNugst7K9Bd2FTR4Mi
2026-12-06 22:18:55 +00:00

61 lines
2.3 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# Acceptance test for issue #177: deployed plugin content must not carry this
# repo's internal references, because it ships into consumer repos where those
# references point nowhere.
#
# * git and gitea `.apm/` content: no Co-authored-by trailer examples (any
# case), no ADR citations (`ADR-0`, `docs/adr`), no `Mortis/Holocron` slug.
# * git, gitea, delivery, core and kyberforge `.apm/` content: no ADR-0023
# (now the `rtk-bare:` marker) and no ADR-0020 (the rule is stated inline).
#
# Other ADR citations in delivery, core and kyberforge are out of #177's scope
# and deliberately not asserted here. Every hit is printed as file:line.
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
PASS=0
FAIL=0
pass() { echo " PASS: $1"; PASS=$((PASS + 1)); }
fail() { echo " FAIL: $1"; FAIL=$((FAIL + 1)); }
# assert_absent <label> <grep flags> <pattern> <plugin>...
# Fails, printing file:line:text for every hit, when <pattern> occurs in any
# named plugin's .apm/ tree. A missing .apm/ dir fails too: a renamed plugin
# must not turn the check vacuous.
assert_absent() {
local label="$1" flags="$2" pattern="$3"
shift 3
local dirs=() plugin hits
for plugin in "$@"; do
if [[ ! -d "$REPO_ROOT/plugins/$plugin/.apm" ]]; then
fail "$label: plugins/$plugin/.apm does not exist"
return
fi
dirs+=("plugins/$plugin/.apm")
done
# grep exits 1 on no match, which is the passing case here. The guarded
# expansion keeps bash 3.2 happy under `set -u`.
hits="$(cd "$REPO_ROOT" && grep -rnI $flags -e "$pattern" -- ${dirs[@]+"${dirs[@]}"} || true)"
if [[ -z "$hits" ]]; then
pass "$label"
else
fail "$label"
printf '%s\n' "$hits" | sed 's/^/ /'
fi
}
echo "Plugin content is consumer-neutral (#177)"
assert_absent "git/gitea: no Co-authored-by" "-i" "Co-authored-by" git gitea
assert_absent "git/gitea: no ADR-0 citation" "" "ADR-0" git gitea
assert_absent "git/gitea: no docs/adr path" "" "docs/adr" git gitea
assert_absent "git/gitea: no Mortis/Holocron slug" "" "Mortis/Holocron" git gitea
assert_absent "no ADR-0023 citation" "" "ADR-0023" git gitea delivery core kyberforge
assert_absent "no ADR-0020 citation" "" "ADR-0020" git gitea delivery core kyberforge
echo ""
echo "Results: $PASS passed, $FAIL failed"
[[ $FAIL -eq 0 ]]