2017-04-21 09:23:45 +00:00
|
|
|
#!/usr/bin/env bash
|
2015-09-15 19:38:54 +00:00
|
|
|
set -e
|
|
|
|
|
2017-11-20 14:26:03 +00:00
|
|
|
if ! test -e autogen/genstatic/gen.go; then
|
2015-11-01 15:35:01 +00:00
|
|
|
echo >&2 'error: generate must be run before test-unit'
|
2015-09-15 19:38:54 +00:00
|
|
|
false
|
|
|
|
fi
|
|
|
|
|
|
|
|
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
|
|
|
|
2016-03-23 22:06:22 +00:00
|
|
|
if [ -n "$VERBOSE" ]; then
|
2019-05-10 15:24:06 +00:00
|
|
|
TESTFLAGS+=(-v)
|
2019-03-15 08:42:03 +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-10 15:24:06 +00:00
|
|
|
go test "${TESTFLAGS[@]}" ./pkg/...
|
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
|