Add new cover bundlescript for giving a nice report across all the coverprofiles generated by the test scripts
This commit is contained in:
parent
23ab0af2ff
commit
59dc2876a7
3 changed files with 39 additions and 1 deletions
|
@ -65,6 +65,9 @@ RUN git clone https://git.fedorahosted.org/git/lvm2.git /usr/local/lvm2 && cd /u
|
|||
RUN cd /usr/local/lvm2 && ./configure --enable-static_link && make device-mapper && make install_device-mapper
|
||||
# see https://git.fedorahosted.org/cgit/lvm2.git/tree/INSTALL
|
||||
|
||||
# Grab Go's cover tool for dead-simple code coverage testing
|
||||
RUN go get code.google.com/p/go.tools/cmd/cover
|
||||
|
||||
VOLUME /var/lib/docker
|
||||
WORKDIR /go/src/github.com/dotcloud/docker
|
||||
|
||||
|
|
16
hack/make.sh
16
hack/make.sh
|
@ -39,6 +39,7 @@ DEFAULT_BUNDLES=(
|
|||
dynbinary
|
||||
dyntest
|
||||
dyntest-integration
|
||||
cover
|
||||
tgz
|
||||
ubuntu
|
||||
)
|
||||
|
@ -64,6 +65,11 @@ LDFLAGS='-X main.GITCOMMIT "'$GITCOMMIT'" -X main.VERSION "'$VERSION'" -w'
|
|||
LDFLAGS_STATIC='-X github.com/dotcloud/docker/utils.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"'
|
||||
BUILDFLAGS='-tags netgo'
|
||||
|
||||
HAVE_GO_TEST_COVER=
|
||||
if go help testflag | grep -q -- -cover; then
|
||||
HAVE_GO_TEST_COVER=1
|
||||
fi
|
||||
|
||||
# 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.
|
||||
#
|
||||
|
@ -71,6 +77,14 @@ BUILDFLAGS='-tags netgo'
|
|||
#
|
||||
go_test_dir() {
|
||||
dir=$1
|
||||
testcover=()
|
||||
if [ "$HAVE_GO_TEST_COVER" ]; then
|
||||
# if our current go install has -cover, we want to use it :)
|
||||
mkdir -p "$DEST/coverprofiles"
|
||||
coverprofile="docker${dir#.}"
|
||||
coverprofile="$DEST/coverprofiles/${coverprofile//\//-}"
|
||||
testcover=( -cover -coverprofile "$coverprofile" )
|
||||
fi
|
||||
( # we run "go test -i" ouside the "set -x" to provde cleaner output
|
||||
cd "$dir"
|
||||
go test -i -ldflags "$LDFLAGS" $BUILDFLAGS
|
||||
|
@ -78,7 +92,7 @@ go_test_dir() {
|
|||
(
|
||||
set -x
|
||||
cd "$dir"
|
||||
go test -ldflags "$LDFLAGS" $BUILDFLAGS $TESTFLAGS
|
||||
go test ${testcover[@]} -ldflags "$LDFLAGS" $BUILDFLAGS $TESTFLAGS
|
||||
)
|
||||
}
|
||||
|
||||
|
|
21
hack/make/cover
Normal file
21
hack/make/cover
Normal file
|
@ -0,0 +1,21 @@
|
|||
#!/bin/bash
|
||||
|
||||
DEST="$1"
|
||||
|
||||
bundle_cover() {
|
||||
coverprofiles=( "$DEST/../"*"/coverprofiles/"* )
|
||||
for p in "${coverprofiles[@]}"; do
|
||||
echo
|
||||
(
|
||||
set -x
|
||||
go tool cover -func="$p"
|
||||
)
|
||||
done
|
||||
}
|
||||
|
||||
if [ "$HAVE_GO_TEST_COVER" ]; then
|
||||
bundle_cover 2>&1 | tee "$DEST/report.log"
|
||||
else
|
||||
echo >&2 'warning: the current version of go does not support -cover'
|
||||
echo >&2 ' skipping test coverage report'
|
||||
fi
|
Loading…
Reference in a new issue