2022-03-09 13:45:36 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eu
|
|
|
|
|
|
|
|
die() {
|
|
|
|
echo >&2 "$@"
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
# shellcheck disable=SC1007
|
|
|
|
TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
|
|
|
# shellcheck source=./.environment.sh
|
|
|
|
. "${TEST_DIR}/.environment.sh"
|
|
|
|
|
2022-10-04 13:58:10 +00:00
|
|
|
"${TEST_DIR}/bin/check-requirements"
|
2022-03-09 13:45:36 +00:00
|
|
|
|
2022-03-21 14:51:05 +00:00
|
|
|
echo "Running tests..."
|
2022-06-13 19:54:47 +00:00
|
|
|
echo "DB_BACKEND: ${DB_BACKEND}"
|
|
|
|
if [[ -z "${TEST_COVERAGE}" ]]; then
|
2022-04-05 09:00:11 +00:00
|
|
|
echo "Coverage report: no"
|
|
|
|
else
|
|
|
|
echo "Coverage report: yes"
|
|
|
|
fi
|
|
|
|
|
2022-03-21 14:51:05 +00:00
|
|
|
dump_backend="$(cat "${LOCAL_INIT_DIR}/.backend")"
|
2022-06-13 19:54:47 +00:00
|
|
|
if [[ "${DB_BACKEND}" != "${dump_backend}" ]]; then
|
|
|
|
die "Can't run with backend '${DB_BACKEND}' because the test data was build with '${dump_backend}'"
|
2022-03-21 14:51:05 +00:00
|
|
|
fi
|
|
|
|
|
2022-06-13 19:54:47 +00:00
|
|
|
if [[ $# -ge 1 ]]; then
|
2022-03-21 14:51:05 +00:00
|
|
|
echo "test files: $*"
|
2022-03-09 13:45:36 +00:00
|
|
|
"${TEST_DIR}/lib/bats-core/bin/bats" \
|
|
|
|
--jobs 1 \
|
2022-06-13 19:54:47 +00:00
|
|
|
--timing \
|
2022-06-17 14:12:49 +00:00
|
|
|
--print-output-on-failure \
|
2022-05-28 20:10:27 +00:00
|
|
|
"$@"
|
2022-03-09 13:45:36 +00:00
|
|
|
else
|
2022-03-21 14:51:05 +00:00
|
|
|
echo "test files: ${TEST_DIR}/bats ${TEST_DIR}/dyn-bats"
|
2022-03-09 13:45:36 +00:00
|
|
|
"${TEST_DIR}/lib/bats-core/bin/bats" \
|
|
|
|
--jobs 1 \
|
2022-06-17 14:12:49 +00:00
|
|
|
--timing \
|
2022-03-09 13:45:36 +00:00
|
|
|
--print-output-on-failure \
|
2022-06-17 14:12:49 +00:00
|
|
|
"${TEST_DIR}/bats" "${TEST_DIR}/dyn-bats"
|
2022-03-09 13:45:36 +00:00
|
|
|
fi
|