2017-04-21 09:23:45 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-09-15 19:38:54 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
RED=$'\033[31m'
|
|
|
|
GREEN=$'\033[32m'
|
|
|
|
TEXTRESET=$'\033[0m' # reset the foreground colour
|
|
|
|
|
2019-03-15 08:42:03 +00:00
|
|
|
# -failfast -timeout=5m
|
2019-05-10 15:24:06 +00:00
|
|
|
TESTFLAGS=(-cover "-coverprofile=cover.out" "${TESTFLAGS}")
|
2015-09-15 19:38:54 +00:00
|
|
|
|
2022-09-14 13:10:08 +00:00
|
|
|
if [ -n "${VERBOSE}" ]; then
|
2019-05-10 15:24:06 +00:00
|
|
|
TESTFLAGS+=(-v)
|
2022-09-14 13:10:08 +00:00
|
|
|
elif [ -n "${VERBOSE_UNIT}" ]; then
|
2019-05-10 15:24:06 +00:00
|
|
|
TESTFLAGS+=(-v)
|
2016-03-23 22:06:22 +00:00
|
|
|
fi
|
|
|
|
|
2019-03-15 08:42:03 +00:00
|
|
|
set +e
|
2015-09-15 19:38:54 +00:00
|
|
|
|
2019-05-14 17:58:04 +00:00
|
|
|
# shellcheck disable=SC2086
|
2022-09-14 13:10:08 +00:00
|
|
|
# shellcheck disable=SC2048
|
2023-11-22 18:18:05 +00:00
|
|
|
go test ${TESTFLAGS[*]} ./pkg/... ./cmd/...
|
2015-09-15 19:38:54 +00:00
|
|
|
|
2019-03-15 08:42:03 +00:00
|
|
|
CODE=$?
|
|
|
|
if [ ${CODE} != 0 ]; then
|
|
|
|
echo "${RED}Tests failed [code ${CODE}].${TEXTRESET}"
|
|
|
|
exit ${CODE}
|
2015-09-15 19:38:54 +00:00
|
|
|
else
|
2019-03-15 08:42:03 +00:00
|
|
|
echo "${GREEN}Tests succeed.${TEXTRESET}"
|
2015-09-15 19:38:54 +00:00
|
|
|
fi
|