Files
holocron/tests/run-bats.sh
Defame1297 fddf39e396 fix(tests): exclude .claude/worktrees/ from test-file discovery
find-based discovery in run-bats.sh and run-tests.sh picked up test
files nested inside on-disk git worktree checkouts under
.claude/worktrees/ (untracked, created by background agent isolation),
whose submodule-based test_helper isn't initialized there — causing
spurious pre-push failures unrelated to any real change.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-05 13:57:46 +00:00

33 lines
817 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/*" \
-not -path "*/.claude/worktrees/*" \
| sort
)
if [[ ${#TEST_FILES[@]} -eq 0 ]]; then
echo "No .bats test files found." >&2
exit 0
fi
"$BATS" "${TEST_FILES[@]}"