talos/hack/golang/test.sh
Andrey Smirnov 2fb00344ab chore: upgrade Go to 1.14.3 and use toolchain for race detector
With Go 1.14.3 we can run race-enabled code on muslc, so this opens path
to run unit-tests-race under Talos environment with rootfs, enabling all
the tests to run under race detector.

Also fixed the tests run by specifying platform in the test environment.

Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
2020-05-25 08:35:11 -07:00

38 lines
605 B
Bash
Executable File

#!/bin/sh
set -e
# Set up common test environment variables
export PLATFORM=container
perform_tests() {
echo "Performing tests on $1"
go test -v -covermode=atomic -coverprofile=coverage.txt -count 1 "$1"
}
perform_race_tests() {
echo "Performing race tests on $1"
CGO_ENABLED=1 go test -v -race -count 1 "$1"
}
perform_short_tests() {
echo "Performing short tests on $1"
go test -v -short -count 1 "$1"
}
case $1 in
--race)
shift
perform_race_tests "${1:-./...}"
;;
--short)
shift
perform_short_tests "${1:-./...}"
;;
*)
perform_tests "${1:-./...}"
;;
esac
exit 0