summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2022-07-27 03:30:04 +0700
committerShulhan <ms@kilabit.info>2022-07-27 03:30:04 +0700
commitcf3761a7ce3270bf44ad405cc10378ea49bd1d80 (patch)
tree5dcfd692f19b6e3b324a0f1465a9cb5bfdef5ba7
parentb1e829a026bd7809cebe689f1178570074b3312c (diff)
downloadpakakeh.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.sh12
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