From d92a14764440a067628b83ac3782fd36ab7e4956 Mon Sep 17 00:00:00 2001 From: Michael McLoughlin Date: Wed, 2 Jan 2019 20:41:59 -0800 Subject: [PATCH] testing: coverage script Updates #27 --- .gitignore | 1 + .travis.yml | 1 + script/bootstrap | 3 +++ script/coverage | 21 +++++++++++++++++++++ 4 files changed, 26 insertions(+) create mode 100644 .gitignore create mode 100755 script/coverage diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7823778 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.coverprofile diff --git a/.travis.yml b/.travis.yml index d182b5b..39ddb5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,5 @@ install: script: - go build ./... - go test -bench . ./... +- ./script/coverage - ./script/lint diff --git a/script/bootstrap b/script/bootstrap index dff10b3..78b4a25 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -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 diff --git a/script/coverage b/script/coverage new file mode 100755 index 0000000..4ebadb3 --- /dev/null +++ b/script/coverage @@ -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}