Files
Holocron/tests/test-plugin-content-consumer-neutral.sh
T
Defame1297andClaude Opus 5.5 08fcc8be56 test(plugins): assert git and gitea content is consumer-neutral
Add an acceptance test for #177. It fails, printing file:line, when the
git or gitea .apm/ content carries a Co-authored-by trailer example, an
ADR citation or docs/adr path, or the Mortis/Holocron slug, or when any
of git, gitea, delivery, core and kyberforge cite ADR-0023 or ADR-0020.
run-tests picks it up as a tracked tests/test-*.sh suite.

Refs: #177

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

60 lines
2.2 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.
hits="$(cd "$REPO_ROOT" && grep -rnI $flags -e "$pattern" -- "${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 ]]