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"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
check_requirements() {
|
2022-03-10 12:59:10 +00:00
|
|
|
if ! command -v python3 >/dev/null; then
|
|
|
|
die "missing required program 'python3'"
|
|
|
|
fi
|
|
|
|
|
2022-03-09 13:45:36 +00:00
|
|
|
if ! command -v nc >/dev/null; then
|
|
|
|
die "missing required program 'nc' (package 'netcat-openbsd')"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! command -v yq >/dev/null; then
|
2022-03-10 11:19:02 +00:00
|
|
|
die "missing required program 'yq'. You can install it with 'GO111MODULE=on go get github.com/mikefarah/yq/v4' and add ~/go/bin to $PATH"
|
2022-03-09 13:45:36 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
SYSTEM=$(uname -s)
|
|
|
|
case "${SYSTEM,,}" in
|
|
|
|
linux)
|
|
|
|
if ! command -v daemonize >/dev/null; then
|
|
|
|
die "missing required program 'daemonize' (package 'daemonize')"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
freebsd)
|
|
|
|
if ! command -v daemon >/dev/null; then
|
|
|
|
die "missing required program 'daemon'"
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
die "unsupported system: $SYSTEM"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
check_requirements
|
|
|
|
|
|
|
|
if [ $# -ge 1 ]; then
|
|
|
|
"${TEST_DIR}/lib/bats-core/bin/bats" \
|
|
|
|
--jobs 1 \
|
|
|
|
--print-output-on-failure \
|
|
|
|
-T "$@"
|
|
|
|
else
|
|
|
|
"${TEST_DIR}/lib/bats-core/bin/bats" \
|
|
|
|
--jobs 1 \
|
|
|
|
--print-output-on-failure \
|
|
|
|
-T "${TEST_DIR}/bats" "${TEST_DIR}/dyn-bats"
|
|
|
|
fi
|