allow for testing go:tip

This commit is contained in:
Josh Baker 2016-03-17 12:15:35 -07:00
parent d178133383
commit 865bbf7d19
1 changed files with 41 additions and 40 deletions

View File

@ -14,53 +14,54 @@ if [ "$PROTECTED_MODE" == "no" ]; then
LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.ProtectedMode=no" LDFLAGS="$LDFLAGS -X github.com/tidwall/tile38/core.ProtectedMode=no"
fi fi
# Check go install
if [ "$(which go)" == "" ]; then if [ "$(which go)" == "" ]; then
echo "error: Go is not installed. Please download and follow installation instructions at https://golang.org/dl to continue." echo "error: Go is not installed. Please download and follow installation instructions at https://golang.org/dl to continue."
exit 1 exit 1
fi fi
vercomp () { # Check go version
if [[ $1 == $2 ]]
then
echo "0"
return
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
echo "1"
return
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
echo "-1"
return
fi
done
echo "0"
return
}
GOVERS="$(go version | cut -d " " -f 3)" GOVERS="$(go version | cut -d " " -f 3)"
GOVERS="${GOVERS:2}"
if [ "$GOVERS" != "devel" ]; then if [ "$GOVERS" != "devel" ]; then
vercomp () {
if [[ $1 == $2 ]]
then
echo "0"
return
fi
local IFS=.
local i ver1=($1) ver2=($2)
# fill empty fields in ver1 with zeros
for ((i=${#ver1[@]}; i<${#ver2[@]}; i++))
do
ver1[i]=0
done
for ((i=0; i<${#ver1[@]}; i++))
do
if [[ -z ${ver2[i]} ]]
then
# fill empty fields in ver2 with zeros
ver2[i]=0
fi
if ((10#${ver1[i]} > 10#${ver2[i]}))
then
echo "1"
return
fi
if ((10#${ver1[i]} < 10#${ver2[i]}))
then
echo "-1"
return
fi
done
echo "0"
return
}
GOVERS="${GOVERS:2}"
EQRES=$(vercomp "$GOVERS" "1.5") EQRES=$(vercomp "$GOVERS" "1.5")
if [ "$EQRES" == "-1" ]; then if [ "$EQRES" == "-1" ]; then
echo "error: Go '1.5' or greater is required and '$GOVERS' is currently installed. Please upgrade Go at https://golang.org/dl to continue." echo "error: Go '1.5' or greater is required and '$GOVERS' is currently installed. Please upgrade Go at https://golang.org/dl to continue."
exit 1 exit 1
fi fi
fi fi
@ -72,7 +73,7 @@ OD="$(pwd)"
# temp directory for storing isolated environment. # temp directory for storing isolated environment.
TMP="$(mktemp -d -t tile38.XXXX)" TMP="$(mktemp -d -t tile38.XXXX)"
function rmtemp { function rmtemp {
rm -rf "$TMP" rm -rf "$TMP"
} }
trap rmtemp EXIT trap rmtemp EXIT
@ -101,7 +102,7 @@ if [ "$1" == "test" ]; then
$OD/tile38-server -p 9876 -d "$TMP" -q & $OD/tile38-server -p 9876 -d "$TMP" -q &
PID=$! PID=$!
function testend { function testend {
kill $PID & kill $PID &
} }
trap testend EXIT trap testend EXIT
go test $(go list ./... | grep -v /vendor/) go test $(go list ./... | grep -v /vendor/)