git » chasquid » commit ac2b037

chasquid-util: Include in coverage tests

author Alberto Bertogli
2024-03-06 23:00:08 UTC
committer Alberto Bertogli
2024-03-07 23:07:37 UTC
parent 96fe38c4791759ffa6b5822f17f78df6050f4a68

chasquid-util: Include in coverage tests

This patch adds chasquid-util command-line to the coverage tests, so it is
easier to identify testing gaps.

cmd/chasquid-util/chasquid-util.go +0 -4
cmd/chasquid-util/test.sh +6 -1
test/cover.sh +3 -0

diff --git a/cmd/chasquid-util/chasquid-util.go b/cmd/chasquid-util/chasquid-util.go
index 8325e17..36614d7 100644
--- a/cmd/chasquid-util/chasquid-util.go
+++ b/cmd/chasquid-util/chasquid-util.go
@@ -1,8 +1,4 @@
 // chasquid-util is a command-line utility for chasquid-related operations.
-//
-// Don't include it in the coverage build.
-//go:build !coverage
-// +build !coverage
 
 package main
 
diff --git a/cmd/chasquid-util/test.sh b/cmd/chasquid-util/test.sh
index 6b01665..fccca8a 100755
--- a/cmd/chasquid-util/test.sh
+++ b/cmd/chasquid-util/test.sh
@@ -5,7 +5,12 @@ set -e
 
 init
 
-go build || exit 1
+if [ "${GOCOVERDIR}" != "" ]; then
+	GOFLAGS="-cover -covermode=count -o chasquid-util $GOFLAGS"
+fi
+
+# shellcheck disable=SC2086
+go build $GOFLAGS -tags="$GOTAGS" .
 
 function r() {
 	./chasquid-util -C=.config "$@"
diff --git a/test/cover.sh b/test/cover.sh
index 3f2e874..891ff15 100755
--- a/test/cover.sh
+++ b/test/cover.sh
@@ -37,6 +37,9 @@ GOCOVERDIR="${COVER_DIR}/sh" setsid -w ./test/run.sh
 echo "dovecot cli ..."
 GOCOVERDIR="${COVER_DIR}/sh" setsid -w ./cmd/dovecot-auth-cli/test.sh
 
+echo "chasquid-util ..."
+GOCOVERDIR="${COVER_DIR}/sh" setsid -w ./cmd/chasquid-util/test.sh
+
 # Merge all coverage output into a single file.
 go tool covdata merge -i "${COVER_DIR}/go,${COVER_DIR}/sh" -o "${COVER_DIR}/all"
 go tool covdata textfmt -i "${COVER_DIR}/all" -o "${COVER_DIR}/merged.out"