git » chasquid » commit 9354944

test: Add RACE=1 variable to run with the race detector

author Alberto Bertogli
2016-09-25 19:48:21 UTC
committer Alberto Bertogli
2016-10-09 23:51:04 UTC
parent 1433340ea65c30f211d28e723f79adb53f6253c5

test: Add RACE=1 variable to run with the race detector

It's often useful to run the tests with the race detector (-race) enabled.
Unfortunately, building with it is too slow to enable unconditionally.

So for now this patch adds an option, in the form of an environment variable,
to enable it manually.

test/util/lib.sh +5 -1

diff --git a/test/util/lib.sh b/test/util/lib.sh
index f876039..40b16cb 100644
--- a/test/util/lib.sh
+++ b/test/util/lib.sh
@@ -10,6 +10,10 @@ function init() {
 
 	export UTILDIR="$(realpath ${TBASE}/../util/)"
 
+	if [ "${RACE}" == "1" ]; then
+		RACE="-race"
+	fi
+
 	# Remove the directory where test-mda will deliver mail, so previous
 	# runs don't interfere with this one.
 	rm -rf .mail
@@ -31,7 +35,7 @@ function chasquid() {
 	HOSTALIASES=${TBASE}/hosts \
 	PATH=${UTILDIR}:${PATH} \
 	MDA_DIR=${TBASE}/.mail \
-		go run ${TBASE}/../../chasquid.go "$@"
+		go run ${RACE} ${TBASE}/../../chasquid.go "$@"
 }
 
 function add_user() {