Skip to content

Instantly share code, notes, and snippets.

@arsham
Last active March 29, 2018 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arsham/f45f7e7eea7e18796bc1ed5ced9f9f4a to your computer and use it in GitHub Desktop.
Save arsham/f45f7e7eea7e18796bc1ed5ced9f9f4a to your computer and use it in GitHub Desktop.
Concatinates the test coverages from all folders expect the vendor folder
#!/bin/bash
echo 'mode: atomic' > coverage.txt
go list ./... | grep -v vendor | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp {}
tail -n +2 coverage.tmp >> coverage.txt'
go tool cover -html=coverage.txt
rm coverage.tmp coverage.txt
@arsham
Copy link
Author

arsham commented Dec 20, 2016

Or as a function:

gocover () {
        echo 'mode: atomic' > coverage.txt && go list ./... | xargs -n1 -I{} sh -c 'go test -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.txt' && go tool cover -html=coverage.txt && rm coverage.tmp coverage.txt
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment