Skip to content
This repository has been archived by the owner on May 11, 2022. It is now read-only.

Commit

Permalink
add test-with-coverage-profile
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilsk committed Jan 24, 2019
1 parent 91f6024 commit df162ab
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.out
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
GO_TEST_COVERAGE_MODE ?= count
GO_TEST_COVERAGE_FILENAME ?= cover.out
PACKAGES := go list ./... | grep -v vendor

.PHONY: test-with-coverage-profile
test-with-coverage-profile: #| Runs tests with coverage and collects the result.
#| Uses: GO_TEST_COVERAGE_MODE, GO_TEST_COVERAGE_FILENAME, PACKAGES.
echo 'mode: ${GO_TEST_COVERAGE_MODE}' > '${GO_TEST_COVERAGE_FILENAME}'
for package in $$($(PACKAGES)); do \
go test -covermode '${GO_TEST_COVERAGE_MODE}' \
-coverprofile "coverage_$${package##*/}.out" \
"$${package}"; \
if [ -f "coverage_$${package##*/}.out" ]; then \
sed '1d' "coverage_$${package##*/}.out" >> '${GO_TEST_COVERAGE_FILENAME}'; \
rm "coverage_$${package##*/}.out"; \
fi \
done

0 comments on commit df162ab

Please sign in to comment.