2017-07-05 17:15:59 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
#
|
2019-07-30 20:07:30 -04:00
|
|
|
# Run unit tests and create report
|
2017-07-05 17:15:59 -04:00
|
|
|
#
|
|
|
|
# TESTFLAGS - add additional test flags. Ex:
|
|
|
|
#
|
2019-07-30 20:07:30 -04:00
|
|
|
# TESTFLAGS='-v -run TestBuild' hack/test/unit
|
2017-07-05 17:15:59 -04:00
|
|
|
#
|
|
|
|
# TESTDIRS - run tests for specified packages. Ex:
|
|
|
|
#
|
2019-07-30 20:07:30 -04:00
|
|
|
# TESTDIRS='./pkg/term' hack/test/unit
|
2017-07-05 17:15:59 -04:00
|
|
|
#
|
|
|
|
set -eu -o pipefail
|
|
|
|
|
2019-07-30 20:07:30 -04:00
|
|
|
BUILDFLAGS=( -tags 'netgo seccomp libdm_no_deferred_remove' )
|
|
|
|
TESTFLAGS+="-test.timeout=${TIMEOUT:-5m}"
|
|
|
|
TESTDIRS="${TESTDIRS:-./...}"
|
|
|
|
exclude_paths='/vendor/|/integration'
|
2017-07-05 17:15:59 -04:00
|
|
|
pkg_list=$(go list $TESTDIRS | grep -vE "($exclude_paths)")
|
|
|
|
|
2019-07-30 20:07:30 -04:00
|
|
|
mkdir -p bundles
|
|
|
|
gotestsum --format=standard-quiet --jsonfile=bundles/go-test-report.json --junitfile=bundles/junit-report.xml -- \
|
2019-08-02 09:58:33 -04:00
|
|
|
"${BUILDFLAGS[@]}" \
|
|
|
|
-cover \
|
|
|
|
-coverprofile=bundles/profile.out \
|
|
|
|
-covermode=atomic \
|
|
|
|
${TESTFLAGS} \
|
|
|
|
${pkg_list}
|