#!/bin/bash -e

script_dir=$(cd `dirname $0`; pwd)
root_dir=`dirname $script_dir`

function test_travis
{
	echo "mode: count" > profile.cov

	for pkg in $(cat $root_dir/.test-packages.txt); do
		go test -v -covermode=count -coverprofile=profile_tmp.cov $pkg || exit 1
		[ -f profile_tmp.cov ] && tail -n +2 profile_tmp.cov >> profile.cov;
		rm -f profile_tmp.cov
	done
}

function test_local
{
	go test -v `cat $root_dir/.test-packages.txt`
}

if [ "$CI" = "true" ]; then
	test_travis
else
	test_local
fi

#!/bin/bash -e

script_dir=$(cd `dirname $0`; pwd)
root_dir=`dirname $script_dir`

TEST_FLAGS="-v -race -timeout 5s"

function test_travis
{
	echo "mode: count" > profile.cov

	for pkg in $(cat $root_dir/.test-packages.txt); do
		go test $TEST_FLAGS -covermode=count -coverprofile=profile_tmp.cov $pkg
		[ -f profile_tmp.cov ] && tail -n +2 profile_tmp.cov >> profile.cov;
		rm -f profile_tmp.cov
	done
}

function test_local
{
	go test $TEST_FLAGS `cat $root_dir/.test-packages.txt`
}

if [ "$CI" = "true" ]; then
	test_travis
else
	test_local
fi

Add race detector and timeout to tests
tests: Add race detector and timeout to tests

The sooner we add the race detector, the better. Also limit tests to 5s:
if we end up in a deadlock, the test will fail after that timeout.

Signed-off-by: Damien Lespiau <64bd3cb94f359c1a3ce68dae5e26b40578526277@gmail.com>
