traefik/script/test-unit

33 lines
624 B
Text
Raw Normal View History

#!/usr/bin/env bash
set -e
2017-11-20 14:26:03 +00:00
if ! test -e autogen/genstatic/gen.go; then
echo >&2 'error: generate must be run before test-unit'
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
TESTFLAGS=(-cover "-coverprofile=cover.out" "${TESTFLAGS}")
if [ -n "$VERBOSE" ]; then
TESTFLAGS+=(-v)
2019-03-15 08:42:03 +00:00
elif [ -n "$VERBOSE_UNIT" ]; then
TESTFLAGS+=(-v)
fi
2019-03-15 08:42:03 +00:00
set +e
go test "${TESTFLAGS[@]}" ./pkg/...
2019-03-15 08:42:03 +00:00
CODE=$?
if [ ${CODE} != 0 ]; then
echo "${RED}Tests failed [code ${CODE}].${TEXTRESET}"
exit ${CODE}
else
2019-03-15 08:42:03 +00:00
echo "${GREEN}Tests succeed.${TEXTRESET}"
fi