Files
holocron/tests/run-bats.sh
Defame1297 096120d12e fix(tests): auto-init submodules when bats binary is missing
Fresh worktrees don't have submodules checked out, so the pre-push
run-tests hook failed on first push with a manual-fix error message.
run-bats.sh now runs `git submodule update --init --recursive`
automatically instead of just printing instructions.

Also records two lessons from working across bare-repo/worktree
boundaries this session: the repo root has no working tree (edits
there are invisible to git), and local remote-tracking refs go stale
after a merge — verify via the Gitea API before asking about cleanup.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FNJWdVvdgvZCHi1hZGqgVQ
2026-07-05 13:47:39 +00:00

32 lines
772 B
Bash
Executable File

#!/usr/bin/env bash
# Run all bats test files in the repo.
# Usage: bash tests/run-bats.sh
set -euo pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
BATS="$REPO_ROOT/tests/bats/bin/bats"
if [[ ! -x "$BATS" ]]; then
echo "bats not found at $BATS — initializing submodules..." >&2
git -C "$REPO_ROOT" submodule update --init --recursive
fi
if [[ ! -x "$BATS" ]]; then
echo "Error: bats still not found at $BATS after submodule init" >&2
exit 1
fi
mapfile -t TEST_FILES < <(
find "$REPO_ROOT" -name "*.bats" \
-not -path "*/tests/bats/*" \
-not -path "*/test_helper/*" \
| sort
)
if [[ ${#TEST_FILES[@]} -eq 0 ]]; then
echo "No .bats test files found." >&2
exit 0
fi
"$BATS" "${TEST_FILES[@]}"