testing: coverage script

Updates #27
This commit is contained in:
Michael McLoughlin
2019-01-02 20:41:59 -08:00
parent cf76c56dfc
commit d92a147644
4 changed files with 26 additions and 0 deletions

View File

@@ -11,3 +11,6 @@ curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh |
# embedmd required for documentation generation
go get -u github.com/campoy/embedmd
# covertool for merging coverage reports
go get -u github.com/dlespiau/covertool

21
script/coverage Executable file
View File

@@ -0,0 +1,21 @@
#!/bin/bash -e
ext=".coverprofile"
# Clean existing coverage files.
find . -name '*'${ext} | xargs rm -f
# Unit test coverage.
go test -covermode=count -coverprofile=unit${ext} ./...
# Integration test coverage.
find . -name 'asm.go' | while read main; do
dir=$(dirname ${main})
name=$(basename ${dir})
coverprofile="${dir}/${name}${ext}"
./script/covermain ${main} ${coverprofile} > /dev/null
done
# Merge.
all="all${ext}"
find . -name '*'${ext} | xargs covertool merge --output ${all}