mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
fac486d0a0
This fix tries to address the issue raised by #33856 where `make test-unit` will result in the failure: ``` ... ... dockerversion/useragent.go:20: undefined: Version dockerversion/useragent.go:22: undefined: GitCommit ok github.com/docker/docker/api 0.026s coverage: 68.0% of statements ok github.com/docker/docker/api/errors 0.003s coverage: 100.0% of statements FAIL github.com/docker/docker/api/server [build failed] make: *** [test-unit] Error 2 ``` The issue is because in case of `make test-unit`, `source "${MAKEDIR}/.go-autogen"` is missing. This caused the `make test-unit` failure. This fix adds `source "${MAKEDIR}/.go-autogen"` in `hack/make/test-unit` This fix fixes #33856. Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
58 lines
1.7 KiB
Bash
58 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Run Docker's 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, e.g.
|
|
#
|
|
# TESTFLAGS='-test.run ^TestBuild$' ./hack/make.sh test-unit
|
|
#
|
|
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
|
|
|
|
source "${MAKEDIR}/.go-autogen"
|
|
|
|
if [ "$(go env GOHOSTOS)" = 'solaris' ]; then
|
|
pkg_list=$(go list -e \
|
|
-f '{{if ne .Name "github.com/docker/docker"}}
|
|
{{.ImportPath}}
|
|
{{end}}' \
|
|
"${BUILDFLAGS[@]}" $TEST_PATH \
|
|
| grep github.com/docker/docker \
|
|
| grep -v github.com/docker/docker/vendor \
|
|
| grep -v github.com/docker/docker/daemon/graphdriver \
|
|
| grep -v github.com/docker/docker/man \
|
|
| grep -v github.com/docker/docker/integration-cli)
|
|
else
|
|
pkg_list=$(go list -e \
|
|
-f '{{if ne .Name "github.com/docker/docker"}}
|
|
{{.ImportPath}}
|
|
{{end}}' \
|
|
"${BUILDFLAGS[@]}" $TEST_PATH \
|
|
| grep github.com/docker/docker \
|
|
| grep -v github.com/docker/docker/vendor \
|
|
| grep -v github.com/docker/docker/man \
|
|
| grep -v github.com/docker/docker/integration-cli)
|
|
fi
|
|
|
|
go test -cover -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS $pkg_list
|
|
go test -cover -ldflags "$LDFLAGS" "${BUILDFLAGS[@]}" $TESTFLAGS github.com/docker/docker/pkg/term -test.root
|
|
}
|
|
|
|
bundle_test_unit 2>&1 | tee -a "$DEST/test.log"
|