mirror of
https://github.com/crowdsecurity/crowdsec.git
synced 2025-05-11 12:25:53 +02:00
tests: prevent "make bats-fixture" to run if instance-data is locked (#3201)
* tests: prevent "make bats-fixture" to run if instance-data is locked * lint
This commit is contained in:
parent
fb0117e778
commit
ace942a36d
2 changed files with 21 additions and 11 deletions
|
@ -1,16 +1,26 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
die() {
|
||||
echo >&2 "$@"
|
||||
exit 1
|
||||
}
|
||||
|
||||
#shellcheck disable=SC1007
|
||||
THIS_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
cd "$THIS_DIR" || exit 1
|
||||
# shellcheck disable=SC1091
|
||||
. ./.environment.sh
|
||||
|
||||
if [[ -f "$LOCAL_INIT_DIR/.lock" ]] && [[ "$1" != "unlock" ]]; then
|
||||
die "init data is locked: are you doing some manual test? if so, please finish what you are doing, run 'instance-data unlock' and retry"
|
||||
fi
|
||||
|
||||
backend_script="./lib/config/config-${CONFIG_BACKEND}"
|
||||
|
||||
if [[ ! -x "$backend_script" ]]; then
|
||||
echo "unknown config backend '${CONFIG_BACKEND}'" >&2
|
||||
exit 1
|
||||
die "unknown config backend '${CONFIG_BACKEND}'"
|
||||
fi
|
||||
|
||||
exec "$backend_script" "$@"
|
||||
|
|
|
@ -10,12 +10,12 @@ die() {
|
|||
# shellcheck disable=SC1007
|
||||
TEST_DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
|
||||
# shellcheck source=./.environment.sh
|
||||
. "${TEST_DIR}/.environment.sh"
|
||||
. "$TEST_DIR/.environment.sh"
|
||||
|
||||
"${TEST_DIR}/bin/check-requirements"
|
||||
"$TEST_DIR/bin/check-requirements"
|
||||
|
||||
echo "Running tests..."
|
||||
echo "DB_BACKEND: ${DB_BACKEND}"
|
||||
echo "DB_BACKEND: $DB_BACKEND"
|
||||
if [[ -z "$TEST_COVERAGE" ]]; then
|
||||
echo "Coverage report: no"
|
||||
else
|
||||
|
@ -24,23 +24,23 @@ fi
|
|||
|
||||
[[ -f "$LOCAL_INIT_DIR/.lock" ]] && die "init data is locked: are you doing some manual test? if so, please finish what you are doing, run 'instance-data unlock' and retry"
|
||||
|
||||
dump_backend="$(cat "${LOCAL_INIT_DIR}/.backend")"
|
||||
dump_backend="$(cat "$LOCAL_INIT_DIR/.backend")"
|
||||
if [[ "$DB_BACKEND" != "$dump_backend" ]]; then
|
||||
die "Can't run with backend '${DB_BACKEND}' because the test data was build with '${dump_backend}'"
|
||||
die "Can't run with backend '$DB_BACKEND' because the test data was build with '$dump_backend'"
|
||||
fi
|
||||
|
||||
if [[ $# -ge 1 ]]; then
|
||||
echo "test files: $*"
|
||||
"${TEST_DIR}/lib/bats-core/bin/bats" \
|
||||
"$TEST_DIR/lib/bats-core/bin/bats" \
|
||||
--jobs 1 \
|
||||
--timing \
|
||||
--print-output-on-failure \
|
||||
"$@"
|
||||
else
|
||||
echo "test files: ${TEST_DIR}/bats ${TEST_DIR}/dyn-bats"
|
||||
"${TEST_DIR}/lib/bats-core/bin/bats" \
|
||||
echo "test files: $TEST_DIR/bats $TEST_DIR/dyn-bats"
|
||||
"$TEST_DIR/lib/bats-core/bin/bats" \
|
||||
--jobs 1 \
|
||||
--timing \
|
||||
--print-output-on-failure \
|
||||
"${TEST_DIR}/bats" "${TEST_DIR}/dyn-bats"
|
||||
"$TEST_DIR/bats" "$TEST_DIR/dyn-bats"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue