2017-07-06 00:15:59 +03:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
|
|
|
# Run unit tests
|
|
|
|
#
|
|
|
|
# TESTFLAGS - add additional test flags. Ex:
|
|
|
|
#
|
|
|
|
# TESTFLAGS="-v -run TestBuild" hack/test/unit
|
|
|
|
#
|
|
|
|
# TESTDIRS - run tests for specified packages. Ex:
|
|
|
|
#
|
|
|
|
# TESTDIRS="./pkg/term" hack/test/unit
|
|
|
|
#
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
|
|
|
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
|
|
|
|
BUILDFLAGS=( -tags "netgo seccomp libdm_no_deferred_remove" )
|
|
|
|
TESTDIRS="${TESTDIRS:-"./..."}"
|
|
|
|
|
2017-07-13 02:13:37 +03:00
|
|
|
exclude_paths="/vendor/|/integration"
|
2017-07-06 00:15:59 +03:00
|
|
|
if [ "$(go env GOHOSTOS)" = 'solaris' ]; then
|
|
|
|
exclude_paths="$exclude_paths|/daemon/graphdriver"
|
|
|
|
fi
|
|
|
|
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")
|
|
|
|
|
|
|
|
go test -cover "${BUILDFLAGS[@]}" $TESTFLAGS $pkg_list
|