Skip to content

Instantly share code, notes, and snippets.

@achilleas-k
Created December 22, 2016 13:26
Show Gist options
  • Save achilleas-k/311e8904c96ba1d8edf5a2f5d96666f1 to your computer and use it in GitHub Desktop.
Save achilleas-k/311e8904c96ba1d8edf5a2f5d96666f1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# exit on error
set -e
# run go test in each package that contains test files (once per package only)
find -iname "*test.go" -execdir [ ! -e covprof.part ] \; -execdir go test -v -covermode=count -coverprofile=covprof.part \;
# prepare global coverage profile
echo "mode: count" > profile.cov
# join parts (filter header lines)
grep -h -v -F "mode: count" --include=covprof.part -r . >> profile.cov
# generate html report thingie
go tool cover -html=profile.cov
# cleanup
find -name "covprof.part" -exec rm {} \;
rm profile.cov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment