blob: 4569be3b9ddad675a9e211c723fb1eee083960ce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/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[@]}"
|