2014-09-09 22:34:55 +04:00
|
|
|
#!/bin/bash -e
|
2014-09-09 10:06:03 +04:00
|
|
|
#
|
|
|
|
# Run all etcd tests
|
|
|
|
# ./test
|
|
|
|
# ./test -v
|
|
|
|
#
|
|
|
|
# Run tests for one package
|
|
|
|
#
|
|
|
|
# PKG=./wal ./test
|
|
|
|
# PKG=snap ./test
|
|
|
|
|
|
|
|
# Invoke ./cover for HTML output
|
|
|
|
COVER=${COVER:-"-cover"}
|
|
|
|
|
|
|
|
source ./build
|
|
|
|
|
2014-09-11 23:48:18 +04:00
|
|
|
TESTABLE="etcdserver etcdserver/etcdhttp etcdserver/etcdserverpb functional proxy raft snap store wait wal"
|
2014-09-09 10:06:03 +04:00
|
|
|
FORMATTABLE="$TESTABLE cors.go main.go"
|
|
|
|
|
|
|
|
# user has not provided PKG override
|
|
|
|
if [ -z "$PKG" ]; then
|
|
|
|
TEST=$TESTABLE
|
|
|
|
FMT=$FORMATTABLE
|
|
|
|
|
|
|
|
# user has provided PKG override
|
|
|
|
else
|
|
|
|
# strip out leading dotslashes and trailing slashes from PKG=./foo/
|
|
|
|
TEST=${PKG/#./}
|
|
|
|
TEST=${TEST/#\//}
|
|
|
|
TEST=${TEST/%\//}
|
|
|
|
|
|
|
|
# only run gofmt on packages provided by user
|
|
|
|
FMT="$TEST"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# split TEST into an array and prepend REPO_PATH to each local package
|
|
|
|
split=(${TEST// / })
|
|
|
|
TEST=${split[@]/#/${REPO_PATH}/}
|
|
|
|
|
|
|
|
echo "Running tests..."
|
2014-09-15 00:08:14 +04:00
|
|
|
go test ${COVER} $@ ${TEST} --race
|
2014-09-09 10:06:03 +04:00
|
|
|
|
|
|
|
echo "Checking gofmt..."
|
|
|
|
fmtRes=$(gofmt -l $FMT)
|
|
|
|
if [ -n "${fmtRes}" ]; then
|
|
|
|
echo -e "gofmt checking failed:\n${fmtRes}"
|
|
|
|
exit 255
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Success"
|