1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-18 14:47:03 +00:00

test: Improve layout of helper binaries

This patch moves the test helper binaries to a "one directory per
helper" layout, and also makes them to be ignored in the coverage build
instead of all builds.

With this change, "go build ./..." will build all binaries including the
test helpers, which helps make sure that module manage automation also
considers them. In particular, this makes "go mod tidy" work fine.
This commit is contained in:
Alberto Bertogli
2022-08-27 18:33:33 +01:00
parent 567ad35122
commit 21e8d50df6
11 changed files with 37 additions and 27 deletions

View File

@@ -27,7 +27,7 @@ export COVER_DIR="$PWD/.coverage"
# the single-binary tests to fail: cross-package expvars confuse the expvarom
# tests, which don't expect any expvars to exists besides the one registered
# in the tests themselves.
for pkg in $(go list ./... | grep -v chasquid/cmd/); do
for pkg in $(go list ./... | grep -v -E 'chasquid/cmd/|chasquid/test'); do
OUT_FILE="$COVER_DIR/pkg-`echo $pkg | sed s+/+_+g`.out"
go test -tags coverage \
-covermode=count \
@@ -45,14 +45,14 @@ setsid -w ./cmd/dovecot-auth-cli/test.sh
# Merge all coverage output into a single file.
# Ignore protocol buffer-generated files, as they are not relevant.
go run "${UTILDIR}/gocovcat.go" .coverage/*.out \
go run "${UTILDIR}/gocovcat/gocovcat.go" .coverage/*.out \
| grep -v ".pb.go:" \
> .coverage/all.out
# Generate reports based on the merged output.
go tool cover -func="$COVER_DIR/all.out" | sort -k 3 -n > "$COVER_DIR/func.txt"
go tool cover -html="$COVER_DIR/all.out" -o "$COVER_DIR/classic.html"
go run "${UTILDIR}/coverhtml.go" \
go run "${UTILDIR}/coverhtml/coverhtml.go" \
-input="$COVER_DIR/all.out" -strip=3 \
-output="$COVER_DIR/coverage.html" \
-title="chasquid coverage report" \