From cc45e7fb446dee6b8559014cb810c4ffb6600916 Mon Sep 17 00:00:00 2001 From: Douglas Daniels Date: Thu, 27 Oct 2016 21:10:44 -0500 Subject: [PATCH] Change to test_cover and ran code coverage across package --- .travis.yml | 5 ++++- Makefile | 5 ++++- test.sh | 12 ------------ test_cover.sh | 10 ++++++++++ 4 files changed, 18 insertions(+), 14 deletions(-) delete mode 100755 test.sh create mode 100755 test_cover.sh diff --git a/.travis.yml b/.travis.yml index 97fcbe4..a991692 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,11 +6,14 @@ go: go_import_path: github.com/dnaeon/go-vcr +before_install: +- go get github.com/modocache/gover + install: - make get script: - - make test + - make test_cover after_success: - bash <(curl -s https://codecov.io/bash) diff --git a/Makefile b/Makefile index cea60ee..16153af 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,9 @@ get: go get -v -t -d ./... test: - ./test.sh + go test -v -race ./... + +test_cover: + ./test_cover.sh .PHONY: get test diff --git a/test.sh b/test.sh deleted file mode 100755 index 88c4e8b..0000000 --- a/test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash - -set -e -echo "" > coverage.txt - -for d in $(go list ./... | grep -v vendor); do - go test -v -race -coverprofile=profile.out -covermode=atomic $d - if [ -f profile.out ]; then - cat profile.out >> coverage.txt - rm profile.out - fi -done diff --git a/test_cover.sh b/test_cover.sh new file mode 100755 index 0000000..0542345 --- /dev/null +++ b/test_cover.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +set -e +echo "" > coverage.txt + +go list -f '"go test -v -race -covermode=atomic -coverprofile={{.Name}}.coverprofile -coverpkg={{range $i, $f := .XTestImports}}{{if eq (printf "%.24s" $f) "github.com/dnaeon/go-vcr" }}{{$f}},{{end}}{{end}}{{.ImportPath}} {{.ImportPath}}"' ./... | grep -v vendor | xargs -I {} bash -c {} + +gover . coverage.txt + +rm *.coverprofile