Files
holocron/tests/test-git-hooks-install.sh
Defame1297 69f395f0f6 chore: remove stale chunk/skills references from vision, scripts, and tests
## Why
The repo moved from a chunk-based delivery model with `.agents/skills/`
as the canonical skill source to a plugin model. Several files retained
references to the old model that were either dead code or misleading
framing.

## Impact
- `tests/test-install.sh`: dead `.agents/skills/` test blocks removed;
  suite now tests only what `install.sh` actually deploys
- `scripts/deploy-manifest.sh`: `DEPLOY_SKILLS_SRC` variable and stale
  `sync.sh (Chunk 6)` comment removed
- `tests/test-git-hooks-install.sh`: fixture stub no longer declares
  the removed `DEPLOY_SKILLS_SRC` variable
- `docs/VISION.md`: chunk delivery framing replaced with plugin model
  language throughout; manual test plan date updated
- `tests/test-instructions-and-docs.sh`: stale test plan date flagged
  as pre-refactor so readers know a re-run is needed

Refs: #15

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-28 20:04:45 +00:00

119 lines
3.9 KiB
Bash
Executable File

#!/usr/bin/env bash
# Tests for the git hook install block in scripts/install.sh.
# Runs install.sh from a temp repo to avoid touching the real .git/hooks/.
set -euo pipefail
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)); }
# ---------------------------------------------------------------------------
# Temp repo setup
#
# install.sh derives REPO_ROOT from the script's own location, so copying it
# into a temp tree makes REPO_ROOT point there, not at the real checkout.
# ---------------------------------------------------------------------------
TEMP_REPO="$(mktemp -d)"
TEMP_HOME="$(mktemp -d)"
trap 'rm -rf "$TEMP_REPO" "$TEMP_HOME"' EXIT
mkdir -p "$TEMP_REPO/scripts"
mkdir -p "$TEMP_REPO/.git/hooks"
# Minimal deploy-manifest.sh — empty deploy lists so install.sh reaches the
# hook-copy block without attempting to copy files that don't exist in the
# temp tree.
cat > "$TEMP_REPO/scripts/deploy-manifest.sh" << 'EOF'
# shellcheck disable=SC2034
DEPLOY_FILES=()
DEPLOY_EXECUTABLES=()
DEPLOY_DIRS=()
EOF
# Copy the real install.sh and git-hooks into the temp repo
cp "$REPO_ROOT/scripts/install.sh" "$TEMP_REPO/scripts/install.sh"
cp -r "$REPO_ROOT/scripts/git-hooks" "$TEMP_REPO/scripts/git-hooks"
HOOKS_SRC="$TEMP_REPO/scripts/git-hooks"
run_install() {
HOME="$TEMP_HOME" bash "$TEMP_REPO/scripts/install.sh" > /dev/null 2>&1
}
# ---------------------------------------------------------------------------
echo "--- hook install: files copied to .git/hooks/ ---"
# ---------------------------------------------------------------------------
run_install
for hook_file in "$HOOKS_SRC"/*; do
[[ -f "$hook_file" ]] || continue
hook_name="$(basename "$hook_file")"
if [[ -f "$TEMP_REPO/.git/hooks/$hook_name" ]]; then
pass "$hook_name installed to .git/hooks/"
else
fail "$hook_name missing from .git/hooks/"
fi
done
# ---------------------------------------------------------------------------
echo ""
echo "--- hook install: installed hooks are executable ---"
# ---------------------------------------------------------------------------
for hook_file in "$HOOKS_SRC"/*; do
[[ -f "$hook_file" ]] || continue
hook_name="$(basename "$hook_file")"
if [[ -x "$TEMP_REPO/.git/hooks/$hook_name" ]]; then
pass "$hook_name is executable"
else
fail "$hook_name is not executable"
fi
done
# ---------------------------------------------------------------------------
echo ""
echo "--- hook install: directories in git-hooks/ are not installed ---"
# ---------------------------------------------------------------------------
# Add a subdirectory to scripts/git-hooks/ — the install block must skip it
mkdir -p "$HOOKS_SRC/not-a-hook"
run_install
if [[ ! -e "$TEMP_REPO/.git/hooks/not-a-hook" ]]; then
pass "directories in scripts/git-hooks/ are not copied to .git/hooks/"
else
fail "a directory from scripts/git-hooks/ was incorrectly installed"
fi
rmdir "$HOOKS_SRC/not-a-hook"
# ---------------------------------------------------------------------------
echo ""
echo "--- hook install: idempotent ---"
# ---------------------------------------------------------------------------
run_install
for hook_file in "$HOOKS_SRC"/*; do
[[ -f "$hook_file" ]] || continue
hook_name="$(basename "$hook_file")"
if diff -q "$hook_file" "$TEMP_REPO/.git/hooks/$hook_name" > /dev/null 2>&1; then
pass "idempotent: $hook_name content unchanged after second install"
else
fail "idempotent: $hook_name content corrupted after second install"
fi
if [[ -x "$TEMP_REPO/.git/hooks/$hook_name" ]]; then
pass "idempotent: $hook_name still executable after second install"
else
fail "idempotent: $hook_name lost executable bit after second install"
fi
done
# ---------------------------------------------------------------------------
echo ""
echo "Results: $PASS passed, $FAIL failed"
[[ $FAIL -eq 0 ]]