mirror of https://github.com/docker/docs.git
Add structure to generate code coverage representation
Signed-off-by: Nathan LeClaire <nathan.leclaire@gmail.com>
This commit is contained in:
parent
a57917045c
commit
d1fdc87f54
|
|
@ -2,7 +2,14 @@ language: go
|
|||
sudo: false
|
||||
go:
|
||||
- 1.3
|
||||
install:
|
||||
- export GOPATH=${TRAVIS_BUILD_DIR}/Godeps/_workspace:$GOPATH
|
||||
- export PATH=${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH
|
||||
- go get -t -v ./...
|
||||
- go get code.google.com/p/go.tools/cmd/cover
|
||||
script:
|
||||
- script/validate-dco
|
||||
- script/validate-gofmt
|
||||
- go test -v -short ./...
|
||||
- rm -rf $HOME/.docker
|
||||
- script/generate-coverage
|
||||
|
|
|
|||
|
|
@ -1,11 +1,16 @@
|
|||
FROM golang:1.3-cross
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends openssh-client
|
||||
|
||||
# TODO: Vendor these `go get` commands using Godep.
|
||||
RUN go get github.com/mitchellh/gox
|
||||
RUN go get github.com/aktau/github-release
|
||||
RUN go get github.com/tools/godep
|
||||
RUN go get code.google.com/p/go.tools/cmd/cover
|
||||
|
||||
ENV GOPATH /go/src/github.com/docker/machine/Godeps/_workspace:/go
|
||||
ENV MACHINE_BINARY /go/src/github.com/docker/machine/docker-machine
|
||||
ENV USER root
|
||||
|
||||
WORKDIR /go/src/github.com/docker/machine
|
||||
|
||||
ADD . /go/src/github.com/docker/machine
|
||||
|
|
|
|||
22
README.md
22
README.md
|
|
@ -330,6 +330,28 @@ pass an argument to that script to specify which directory, e.g.:
|
|||
If you make a pull request, it is highly encouraged that you submit tests for
|
||||
the code that you have added or modified in the same pull request.
|
||||
|
||||
## Code Coverage
|
||||
|
||||
Machine includes a script to check for missing `*_test.go` files and to generate
|
||||
an [HTML-based repesentation of which code is covered by tests](http://blog.golang.org/cover#TOC_5.).
|
||||
|
||||
To run the code coverage script, execute:
|
||||
|
||||
```console
|
||||
$ ./script/coverage serve
|
||||
```
|
||||
|
||||
You will see the results of the code coverage check as they come in.
|
||||
|
||||
This will also generate the code coverage website and serve it from a container
|
||||
on port 8000. By default, `/` will show you the source files from the base
|
||||
directory, and you can navigate to the coverage for any particular subdirectory
|
||||
of the Docker Machine repo's root by going to that path. For instance, to see
|
||||
the coverage for the VirtualBox driver's package, browse to `/drivers/virtualbox`.
|
||||
|
||||

|
||||
|
||||
You can hit `CTRL+C` to stop the server.
|
||||
|
||||
## Integration Tests
|
||||
There is a suite of integration tests that will run for the drivers. In order
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 189 KiB |
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package amz
|
||||
|
|
@ -0,0 +1 @@
|
|||
package azure
|
||||
|
|
@ -0,0 +1 @@
|
|||
package digitalocean
|
||||
|
|
@ -0,0 +1 @@
|
|||
package google
|
||||
|
|
@ -0,0 +1 @@
|
|||
package google
|
||||
|
|
@ -0,0 +1 @@
|
|||
package google
|
||||
|
|
@ -0,0 +1 @@
|
|||
package none
|
||||
|
|
@ -0,0 +1 @@
|
|||
package openstack
|
||||
|
|
@ -0,0 +1 @@
|
|||
package openstack
|
||||
|
|
@ -0,0 +1 @@
|
|||
package rackspace
|
||||
|
|
@ -0,0 +1 @@
|
|||
package rackspace
|
||||
|
|
@ -0,0 +1 @@
|
|||
package softlayer
|
||||
|
|
@ -0,0 +1 @@
|
|||
package softlayer
|
||||
|
|
@ -0,0 +1 @@
|
|||
package virtualbox
|
||||
|
|
@ -0,0 +1 @@
|
|||
package virtualbox
|
||||
|
|
@ -0,0 +1 @@
|
|||
package virtualbox
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarefusion
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarefusion
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarefusion
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarevcloudair
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package errors
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarevsphere
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarevsphere
|
||||
|
|
@ -0,0 +1 @@
|
|||
package vmwarevsphere
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
docker build -t docker-machine .
|
||||
|
||||
if [[ "$1" == "serve" ]]; then
|
||||
SERVE=yes
|
||||
else
|
||||
SERVE=no
|
||||
fi
|
||||
|
||||
docker run -it \
|
||||
-e IN_CONTAINER=yes \
|
||||
-e SERVE=${SERVE} \
|
||||
-p 8000:8000 \
|
||||
--rm docker-machine \
|
||||
./script/generate-coverage
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
COVERAGE_DIR=/tmp/coverage
|
||||
|
||||
generate_coverage_for_dir () {
|
||||
echo
|
||||
echo "Generating coverage report for $1..."
|
||||
cd "$1" >/dev/null
|
||||
PKG_COVERAGE_DIR=${COVERAGE_DIR}/"$1"
|
||||
PKG_PROFILE=${PKG_COVERAGE_DIR}/profile.txt
|
||||
mkdir -p ${PKG_COVERAGE_DIR}
|
||||
go test -covermode=set -coverprofile=${PKG_PROFILE}
|
||||
go tool cover -html=${PKG_PROFILE} -o ${PKG_COVERAGE_DIR}/index.html
|
||||
cd - >/dev/null
|
||||
echo "Done generating coverage for $1."
|
||||
for f in $(ls "$1"); do
|
||||
REL_PATH="$1/$f"
|
||||
for exclude in ${EXCLUDED_DIRS}; do
|
||||
if [[ "$REL_PATH" == "$exclude" ]]; then
|
||||
continue 2
|
||||
fi
|
||||
done
|
||||
# If file is directory and not Godeps
|
||||
# (don't worry about generating 3rd party code coverage)
|
||||
if [[ -d "$REL_PATH" ]]; then
|
||||
# invoke recursively
|
||||
generate_coverage_for_dir ${REL_PATH}
|
||||
fi
|
||||
done
|
||||
echo
|
||||
}
|
||||
|
||||
if [[ "$IN_CONTAINER" == "yes" ]]; then
|
||||
cd /go/src/github.com/docker
|
||||
DIR="machine"
|
||||
else
|
||||
DIR="."
|
||||
fi
|
||||
|
||||
# Script will bomb out on some dirs if there are no buildable source files,
|
||||
# we shouldn't be checking these anyway so skip over them.
|
||||
EXCLUDED_DIRS="${DIR}/Godeps ${DIR}/_integration-test ${DIR}/docs ${DIR}/script"
|
||||
|
||||
generate_coverage_for_dir ${DIR}
|
||||
echo "Done checking and generating coverage!"
|
||||
|
||||
if [[ "$SERVE" == "yes" ]]; then
|
||||
cd ${COVERAGE_DIR}/machine
|
||||
echo "*****************************************"
|
||||
echo "* Serving coverage file on port 8000... *"
|
||||
echo "*****************************************"
|
||||
python -m SimpleHTTPServer 8000
|
||||
fi
|
||||
Loading…
Reference in New Issue