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.
33 lines
733 B
Bash
Executable File
33 lines
733 B
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
. "$(dirname "$0")/../../test/util/lib.sh"
|
|
|
|
init
|
|
|
|
# Build the binary once, so we can use it and launch it in chamuyero scripts.
|
|
# Otherwise, we not only spend time rebuilding it over and over, but also "go
|
|
# run" masks the exit code, which is something we care about.
|
|
if [ "${GOCOVERDIR}" != "" ]; then
|
|
GOFLAGS="-cover -covermode=count -o dovecot-auth-cli $GOFLAGS"
|
|
fi
|
|
|
|
# shellcheck disable=SC2086
|
|
go build $GOFLAGS -tags="$GOTAGS" .
|
|
|
|
if ! ./dovecot-auth-cli lalala 2>&1 | grep -q "invalid arguments"; then
|
|
echo "cli worked with invalid arguments"
|
|
exit 1
|
|
fi
|
|
|
|
for i in *.cmy; do
|
|
if ! chamuyero "$i" > "$i.log" 2>&1 ; then
|
|
echo "# Test $i failed, log follows"
|
|
cat "$i.log"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
success
|
|
exit 0
|