diff --git a/.hgignore b/.hgignore index 4e3c3f1..17b7297 100644 --- a/.hgignore +++ b/.hgignore @@ -1,2 +1,3 @@ syntax: glob -bin \ No newline at end of file +bin +cover.out \ No newline at end of file diff --git a/.vendor/pkg/darwin_amd64/golang.org/x/tools/cover.a b/.vendor/pkg/darwin_amd64/golang.org/x/tools/cover.a new file mode 100644 index 0000000..6d88734 Binary files /dev/null and b/.vendor/pkg/darwin_amd64/golang.org/x/tools/cover.a differ diff --git a/Makefile b/Makefile index aefe125..6ab64a1 100644 --- a/Makefile +++ b/Makefile @@ -3,18 +3,19 @@ # derived from: http://zduck.com/2014/go-project-structure-and-dependencies/ # build targets (which aren't files) -.PHONY: build fmt lint vet test autotest run clean env vendor +.PHONY: build fmt lint vet test autotest cover run clean env vendor # configuration APPNAME := docrawler VENDOR := .vendor PACKAGES := \ golang.org/x/tools/cmd/vet \ + golang.org/x/tools/cmd/cover \ github.com/golang/lint/golint # override GOPATH to be our vendor directory -export GOPATH := ${PWD}/${VENDOR} -export PATH := ${PWD}/${VENDOR}/bin:${PATH} +export GOPATH := ${PWD}/${VENDOR}:${PWD} +export PATH := ${PWD}/${VENDOR}/bin:${PWD}/bin:${PATH} default: build @@ -35,24 +36,27 @@ test: autotest: fswatch -or ./src | \ - xargs -n1 -I{} ${SHELL} -c 'echo ; date ; echo ----------------------------; go test ./src/... | ./util/testfilter.sh' + xargs -n1 -I{} ${SHELL} -c 'echo ; date ; echo ----------------------------; go test ./src/... | ./util/testfilter.sh' + +cover: + go test -coverprofile cover.out ./src/... && go tool cover -html cover.out run: build ./bin/${APPNAME} clean: - rm -f ./bin/${APPNAME} + rm -f ./bin/${APPNAME} ./cover.out env: go env # vendor # * wipes our vendor directory completely -# * fetches all packages in ${PACKAGES} +# * fetches all packages in ${PACKAGES} (GOPATH hardcoded to vendor directory only) # * removes source control dirs so packages are vendorable (commitable) vendor: rm -dRf ./${VENDOR}/src && \ - go get -u ${PACKAGES} && \ + GOPATH=${PWD}/${VENDOR} go get -u ${PACKAGES} && \ rm -rf `find ./${VENDOR}/src -type d -name .git` && \ rm -rf `find ./${VENDOR}/src -type d -name .hg` && \ rm -rf `find ./${VENDOR}/src -type d -name .bzr` && \