github.com/crowdsecurity/crowdsec@v1.6.1/test/run-tests (about) 1 #!/usr/bin/env bash 2 3 set -eu 4 5 die() { 6 echo >&2 "$@" 7 exit 1 8 } 9 10 # shellcheck disable=SC1007 11 TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd) 12 # shellcheck source=./.environment.sh 13 . "${TEST_DIR}/.environment.sh" 14 15 "${TEST_DIR}/bin/check-requirements" 16 17 echo "Running tests..." 18 echo "DB_BACKEND: ${DB_BACKEND}" 19 if [[ -z "${TEST_COVERAGE}" ]]; then 20 echo "Coverage report: no" 21 else 22 echo "Coverage report: yes" 23 fi 24 25 dump_backend="$(cat "${LOCAL_INIT_DIR}/.backend")" 26 if [[ "${DB_BACKEND}" != "${dump_backend}" ]]; then 27 die "Can't run with backend '${DB_BACKEND}' because the test data was build with '${dump_backend}'" 28 fi 29 30 if [[ $# -ge 1 ]]; then 31 echo "test files: $*" 32 "${TEST_DIR}/lib/bats-core/bin/bats" \ 33 --jobs 1 \ 34 --timing \ 35 --print-output-on-failure \ 36 "$@" 37 else 38 echo "test files: ${TEST_DIR}/bats ${TEST_DIR}/dyn-bats" 39 "${TEST_DIR}/lib/bats-core/bin/bats" \ 40 --jobs 1 \ 41 --timing \ 42 --print-output-on-failure \ 43 "${TEST_DIR}/bats" "${TEST_DIR}/dyn-bats" 44 fi