diff --git a/Makefile b/Makefile index aa4c0a4e..41fa8afa 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ clean: rm -f tile38-server rm -f tile38-cli test: - @./test.sh + @./build.sh test install: all cp tile38-server /usr/local/bin cp tile38-cli /usr/local/bin diff --git a/build.sh b/build.sh index dbf2d382..482d9d4c 100755 --- a/build.sh +++ b/build.sh @@ -21,6 +21,7 @@ WD="$TMP/src/github.com/tidwall/tile38" GOPATH="$TMP" for file in `find . -type f`; do + # TODO: use .gitignore to ignore, or possibly just use git to determine the file list. if [[ "$file" != "." && "$file" != ./.git* && "$file" != ./data* && "$file" != ./tile38-* ]]; then mkdir -p "$WD/$(dirname "${file}")" cp -P "$file" "$WD/$(dirname "${file}")" @@ -32,5 +33,14 @@ cd $WD go build -ldflags "$LDFLAGS" -o "$OD/tile38-server" cmd/tile38-server/*.go go build -ldflags "$LDFLAGS" -o "$OD/tile38-cli" cmd/tile38-cli/*.go - +# test if requested +if [ "$1" == "test" ]; then + $OD/tile38-server -p 9876 -d "$TMP" -q & + PID=$! + function testend { + kill $PID & + } + trap testend EXIT + go test $(go list ./... | grep -v /vendor/) +fi diff --git a/test.sh b/test.sh deleted file mode 100755 index ee700e1e..00000000 --- a/test.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -cd $(dirname "${BASH_SOURCE[0]}") -WD=$(pwd) - -./build.sh - -TMP="$(mktemp -d -t data-test.XXXX)" -./tile38-server -p 9876 -d "$TMP" -q & -PID=$! -function end { - rm -rf "$TMP" - kill $PID & -} -trap end EXIT - -go test $(go list ./... | grep -v /vendor/)