diff options
| author | Shulhan <ms@kilabit.info> | 2022-07-27 03:30:04 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2022-07-27 03:30:04 +0700 |
| commit | cf3761a7ce3270bf44ad405cc10378ea49bd1d80 (patch) | |
| tree | 5dcfd692f19b6e3b324a0f1465a9cb5bfdef5ba7 | |
| parent | b1e829a026bd7809cebe689f1178570074b3312c (diff) | |
| download | pakakeh.go-cf3761a7ce3270bf44ad405cc10378ea49bd1d80.tar.xz | |
_bin: add script to run Go test and generate HTML coverage
The script accept one single argument: the path to package to
be tested.
If its empty default to current directory and sub-directories.
| -rwxr-xr-x | _bin/go-test-coverhtml.sh | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/_bin/go-test-coverhtml.sh b/_bin/go-test-coverhtml.sh new file mode 100755 index 00000000..11c79e60 --- /dev/null +++ b/_bin/go-test-coverhtml.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +## Script to run go test and generate HTML coverage. +## +## Argument: path to package or default to current package and its +## subdirectory. + +PKGS=${1:-./...} + +CGO_ENABLED=1 +go test -race -p=1 -coverprofile=cover.out ${PKGS} && \ + go tool cover -html=cover.out -o cover.html |
