Last active
January 10, 2021 19:01
-
-
Save rebornwwp/d7e1ee15522353832d6a68a9dcfb7cb1 to your computer and use it in GitHub Desktop.
go_coverage_for_function
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
cover () { | |
local t=$(mktemp -t cover) | |
go test $COVERFLAGS -coverprofile=$t $@ \ | |
&& go tool cover -func=$t \ | |
&& unlink $t | |
} | |
cover-web() { | |
t=$(tempfile) | |
go test $COVERFLAGS -coverprofile=$t $@ && go tool cover -html=$t && unlink $t | |
} | |
# stress test in unit test | |
#!/usr/bin/env bash -e | |
go test -c | |
# comment above and uncomment below to enable the race builder | |
# go test -c -race | |
PKG=$(basename $(pwd)) | |
while true ; do | |
export GOMAXPROCS=$[ 1 + $[ RANDOM % 128 ]] | |
./$PKG.test $@ 2>&1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment