8e5b17cf13
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
54 lines
1.4 KiB
Bash
54 lines
1.4 KiB
Bash
#!/bin/bash
|
|
set -e
|
|
|
|
# Run the test suite, including sub-packages, and store their output as a bundle
|
|
# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'.
|
|
# You can use this to select certain tests to run, eg.
|
|
#
|
|
# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit
|
|
#
|
|
bundle_test_list() {
|
|
go list -e -f '{{range .Imports}}{{.}}{{"\n"}}{{end}}' ./cmd/oci-storage "$@" |\
|
|
grep github.com/containers/storage |\
|
|
grep -v github.com/containers/storage/vendor |\
|
|
grep -v github.com/containers/storage/integration-cli
|
|
}
|
|
bundle_test_unit() {
|
|
TESTFLAGS+=" -test.timeout=${TIMEOUT}"
|
|
INCBUILD="-i"
|
|
count=0
|
|
for flag in "${BUILDFLAGS[@]}"; do
|
|
if [ "${flag}" == ${INCBUILD} ]; then
|
|
unset BUILDFLAGS[${count}]
|
|
break
|
|
fi
|
|
count=$[ ${count} + 1 ]
|
|
done
|
|
|
|
date
|
|
if [ -z "$TESTDIRS" ]; then
|
|
TEST_PATH=./...
|
|
else
|
|
TEST_PATH=./${TESTDIRS}
|
|
fi
|
|
pkg_list=$(
|
|
deps=`bundle_test_list ./cmd/oci-storage`
|
|
newdeps=
|
|
while test "$deps" != "$newdeps" ; do
|
|
deps=${newdeps:-`bundle_test_list ./cmd/oci-storage`}
|
|
newdeps=`for dep in $deps ; do
|
|
bundle_test_list "$dep"
|
|
done | sort -u`
|
|
done
|
|
echo $deps
|
|
)
|
|
go test $COVER $GCCGOFLAGS -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" ${BUILDTAGS:+-tags "${BUILDTAGS}"} $TESTFLAGS $pkg_list
|
|
}
|
|
|
|
|
|
if [[ "$(go version)" == *"gccgo"* ]]; then
|
|
GCCGOFLAGS=-gccgoflags="-lpthread"
|
|
else
|
|
COVER=-cover
|
|
fi
|
|
bundle_test_unit 2>&1 | tee -a "$DEST/test.log"
|