From 139d5ff49fce66d46deefe91d969c36da1327b06 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 28 Jan 2015 10:52:12 -0900 Subject: [PATCH] Coverage. --- shippable.yml | 2 +- test.sh | 23 ++++++++++++++++++++++- testpackages.txt | 3 +++ 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 testpackages.txt diff --git a/shippable.yml b/shippable.yml index 51f3097..07d610f 100644 --- a/shippable.yml +++ b/shippable.yml @@ -21,6 +21,6 @@ before_script: - mkdir -p shippable/codecoverage script: - - go test -coverprofile=coverage.txt -covermode count ./... + - ./test.sh - $GOPATH/bin/gocover-cobertura < coverage.txt > shippable/codecoverage/coverage.xml diff --git a/test.sh b/test.sh index 89a7703..8dd0242 100755 --- a/test.sh +++ b/test.sh @@ -1,4 +1,25 @@ #!/usr/bin/env bash -go test -v ./... +# FROM: https://github.com/getlantern/flashlight-build/blob/devel/testandcover.bash +function die() { + echo $* + exit 1 +} + +export GOPATH=`pwd`:$GOPATH + +echo "mode: count" > coverage.txt + +ERROR="" + +for pkg in `cat testpackages.txt` +do + go test -v -covermode=count -coverprofile=profile_tmp.cov $pkg || ERROR="Error testing $pkg" + tail -n +2 profile_tmp.cov >> coverage.txt || die "Unable to append coverage for $pkg" +done + +if [ ! -z "$ERROR" ] +then + die "Encountered error, last error was: $ERROR" +fi diff --git a/testpackages.txt b/testpackages.txt new file mode 100644 index 0000000..e72f979 --- /dev/null +++ b/testpackages.txt @@ -0,0 +1,3 @@ +github.com/thermokarst/bactdb/models +github.com/thermokarst/bactdb/datastore +github.com/thermokarst/bactdb/api