1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2026-01-09 17:55:57 +00:00

test: Update coverage tests to Go 1.20

Go 1.20 finally includes proper support for instrumenting binaries for
coverage. This allows us to drop quite a few hacks and workarounds that
we used for it, and we can now also test exiting cases.

The downside is that coverage tests now require Go 1.20, but it is an
acceptable price to pay for the more accurate results.

Normal integration tests are unchanged.

This patch updates the coverage testing infrastructure to make use of
the new Go 1.20 features.
This commit is contained in:
Alberto Bertogli
2023-02-01 23:05:00 +00:00
parent 795f2a7ceb
commit 7d6a59ba77
8 changed files with 25 additions and 224 deletions

View File

@@ -27,9 +27,8 @@ function init() {
}
function chasquid() {
if [ "${COVER_DIR}" != "" ]; then
chasquid_cover "$@"
return
if [ "${GOCOVERDIR}" != "" ]; then
GOFLAGS="-cover -covermode=count -o chasquid $GOFLAGS"
fi
# shellcheck disable=SC2086
@@ -44,26 +43,6 @@ function chasquid() {
"${TBASE}/../../chasquid" "$@"
}
function chasquid_cover() {
# Build the coverage-enabled binary.
# See coverage_test.go for more details.
# shellcheck disable=SC2086
( cd "${TBASE}/../../" || exit 1;
go test -covermode=count -coverpkg=./... -c \
-tags="coveragebin $GOTAGS" $GOFLAGS )
# Run the coverage-enabled binary, named "chasquid.test" for hacky
# reasons. See the chasquid function above for details on the
# environment variables.
HOSTALIASES=${TBASE}/hosts \
PATH=${UTILDIR}:${PATH} \
MDA_DIR=${TBASE}/.mail \
"${TBASE}/../../chasquid.test" \
-test.run "^TestRunMain$" \
-test.coverprofile="$COVER_DIR/test-$(date +%s.%N).out" \
"$@"
}
# Add a user with chasquid-util. Because this is somewhat cryptographically
# intensive, it can slow down the tests significantly, so most of the time we
# use the simpler add_user (below) for testing purposes.