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
|
|
|
|
|
2020-03-02 22:27:49 -05:00
|
|
|
BUILDFLAGS=(-tags 'netgo seccomp libdm_no_deferred_remove')
|
2019-09-13 10:01:54 -04:00
|
|
|
TESTFLAGS+=" -test.timeout=${TIMEOUT:-5m}"
|
2019-07-30 20:07:30 -04:00
|
|
|
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}
|