#!/usr/bin/env bash # tests/run_tests.sh # Entry point for the trbldoc test suite. # Requires bats-core: https://github.com/bats-core/bats-core # # Quick install (pick one): # npm install -g bats # brew install bats-core # git clone https://github.com/bats-core/bats-core ~/.bats && ~/.bats/install.sh /usr/local # # Usage: # bash tests/run_tests.sh # run all tests # bash tests/run_tests.sh unit # run only unit tests # bash tests/run_tests.sh integration # run only integration tests set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BATS_TEST_FILENAME:-${BASH_SOURCE[0]}}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)" # ── bats check ────────────────────────────────────────────────────────────── if ! command -v bats &>/dev/null; then echo "ERROR: bats is not installed or not on PATH." >&2 echo "Install with one of:" >&2 echo " npm install -g bats" >&2 echo " brew install bats-core" >&2 echo " git clone https://github.com/bats-core/bats-core ~/.bats && ~/.bats/install.sh /usr/local" >&2 exit 1 fi # ── suite selection ────────────────────────────────────────────────────────── TARGET="${1:-all}" case "$TARGET" in unit) SUITE_DIRS=("$SCRIPT_DIR/unit") ;; integration) SUITE_DIRS=("$SCRIPT_DIR/integration") ;; all) SUITE_DIRS=("$SCRIPT_DIR/unit" "$SCRIPT_DIR/integration") ;; *) echo "Usage: $0 [all|unit|integration]" >&2 exit 1 ;; esac # Export so bats test files can locate project files export REPO_ROOT echo "Running trbldoc test suite (target: $TARGET)" echo "bats $(bats --version)" echo "" bats --print-output-on-failure "${SUITE_DIRS[@]}"