-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun-tests
More file actions
executable file
·33 lines (27 loc) · 1.23 KB
/
run-tests
File metadata and controls
executable file
·33 lines (27 loc) · 1.23 KB
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
#!/usr/bin/env bash
# @description Run the BATS test suite under test/functions/ and test/ci/ in parallel, or forward arguments directly to bats.
# @arg $@ args Optional bats arguments or test file paths; omit to run all tests under test/functions/ and test/ci/.
set -Eeuo pipefail
IFS=$'\n\t'
#shellcheck disable=SC1091
source "${SCRIPTS_DIR}/.functions.bash"
log::enable_err_trap
# pass-through: any arg count valid (forwarded to bats)
readonly BATS_BIN="${SCRIPTS_DIR}/test/bats/bin/bats"
readonly DEFAULT_TARGETS=("${SCRIPTS_DIR}/test/functions" "${SCRIPTS_DIR}/test/ci")
# @description Run bats with default parallel settings or forward all args to bats verbatim.
# @arg $@ args Optional bats arguments forwarded verbatim, or empty to run all tests in parallel.
function main() {
if ! files::exists "${BATS_BIN}"; then
log::die "bats not found at ${BATS_BIN} — run: git submodule update --init --recursive"
fi
if ! commands::executable_exists 'parallel'; then
log::die "GNU parallel not found — required for bats --jobs. Install via your package manager."
fi
if (($# == 0)); then
"${BATS_BIN}" --jobs "$(nproc)" --recursive --print-output-on-failure "${DEFAULT_TARGETS[@]}"
else
"${BATS_BIN}" "$@"
fi
}
main "$@"