Created
February 10, 2019 15:57
-
-
Save Terminator637/d91ade387def0ccbade2ab31e6eedd15 to your computer and use it in GitHub Desktop.
Script that prints the test coverage of the entire package and generates the coverage in HTML
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
touch ./coverage.tmp && | |
echo 'mode: atomic' > coverage.out && | |
go list ./... | grep -v /mocks | grep -v /pb | xargs -n1 -I{} sh -c 'go test -v -race -covermode=atomic -coverprofile=coverage.tmp -coverpkg $(go list ./... | grep -v /mocks | grep -v /pb | tr "\n" ",") {} && tail -n +2 coverage.tmp >> coverage.out || exit 255' && rm coverage.tmp && | |
go tool cover -func=coverage.out && | |
go tool cover -html=coverage.out -o coverage.html && | |
rm coverage.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment