Files
holocron/tests/run-tests.bats
Defame1297 32cd2e3128 test: add run-tests.sh, fix stale tests for marketplace model
- Add tests/run-tests.sh: discovers and runs all test-*.sh (including
  plugin subdirs) and the bats suite; replaces per-script pre-push calls
- Add tests/run-tests.bats: TDD coverage for run-tests.sh behaviours
- Update setup-hooks.sh: pre-push block now calls run-tests.sh
- Fix test-install.sh: remove provider adapter symlink tests (adapter
  removed in marketplace migration), guard skills loops on dir existence
- Fix test-instructions-and-docs.sh: content index checks now point to
  core/AGENTS.md (where it lives), remove ard/bug dir assertions
- Fix test-setup-hooks.sh: assert pre-push hook calls run-tests.sh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-25 19:47:20 +00:00

67 lines
1.8 KiB
Bash

#!/usr/bin/env bats
REPO_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)"
RUN_TESTS="$REPO_ROOT/tests/run-tests.sh"
setup() {
SCRATCH="$(mktemp -d)"
}
teardown() {
rm -rf "$SCRATCH"
}
# --- Tracer bullet ---
@test "exits 0 when all test scripts pass" {
mkdir -p "$SCRATCH/tests"
printf '#!/usr/bin/env bash\necho "ok"\n' > "$SCRATCH/tests/test-one.sh"
chmod +x "$SCRATCH/tests/test-one.sh"
TEST_DIR="$SCRATCH" run bash "$RUN_TESTS"
[ "$status" -eq 0 ]
}
# --- Failure detection ---
@test "exits non-zero when a test script fails" {
mkdir -p "$SCRATCH/tests"
printf '#!/usr/bin/env bash\nexit 1\n' > "$SCRATCH/tests/test-bad.sh"
chmod +x "$SCRATCH/tests/test-bad.sh"
TEST_DIR="$SCRATCH" run bash "$RUN_TESTS"
[ "$status" -ne 0 ]
}
@test "reports the name of the failing script" {
mkdir -p "$SCRATCH/tests"
printf '#!/usr/bin/env bash\nexit 1\n' > "$SCRATCH/tests/test-bad.sh"
chmod +x "$SCRATCH/tests/test-bad.sh"
TEST_DIR="$SCRATCH" run bash "$RUN_TESTS"
[[ "$output" == *"test-bad.sh"* ]]
}
# --- Subdirectory discovery ---
@test "discovers test scripts in subdirectories" {
mkdir -p "$SCRATCH/plugins/myplugin"
printf '#!/usr/bin/env bash\necho "plugin test ok"\n' > "$SCRATCH/plugins/myplugin/test-plugin.sh"
chmod +x "$SCRATCH/plugins/myplugin/test-plugin.sh"
TEST_DIR="$SCRATCH" run bash "$RUN_TESTS"
[ "$status" -eq 0 ]
[[ "$output" == *"test-plugin.sh"* ]]
}
@test "does not pick up scripts not named test-*.sh" {
mkdir -p "$SCRATCH/tests"
printf '#!/usr/bin/env bash\nexit 1\n' > "$SCRATCH/tests/run-bats.sh"
chmod +x "$SCRATCH/tests/run-bats.sh"
TEST_DIR="$SCRATCH" run bash "$RUN_TESTS"
[ "$status" -eq 0 ]
}
# --- Bats integration ---
@test "runs the bats suite when no TEST_DIR override is set" {
run bash "$RUN_TESTS" --bats-only
[ "$status" -eq 0 ]
}