From 3fece6a716def78939b3d3cf8ff41be8aae7e0aa Mon Sep 17 00:00:00 2001 From: Yicheng Qin Date: Mon, 31 Mar 2014 12:18:57 -0700 Subject: [PATCH] feat(test): check format conditions in test And add option '--fmt' in build script to gofmt files automatically. --- build | 6 ++++++ test.sh | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/build b/build index 522b4a243..dd79e8d9a 100755 --- a/build +++ b/build @@ -7,6 +7,12 @@ fi export GOBIN=${PWD}/bin export GOPATH=${PWD} +export GOFMTPATH="./bench ./config ./discovery ./error etcd.go ./http ./log ./machines ./metrics ./mod profile.go ./server ./store ./tests" + +# Don't surprise user by formatting their codes by stealth +if [ "$1" == "--fmt" ]; then + gofmt -s -w -l $GOFMTPATH +fi go install github.com/coreos/etcd go install github.com/coreos/etcd/bench diff --git a/test.sh b/test.sh index f6a6bb58c..42a5075a8 100755 --- a/test.sh +++ b/test.sh @@ -2,6 +2,13 @@ . ./build +fmtRes=`gofmt -l $GOFMTPATH` +if [ "$fmtRes" != "" ]; then + echo "Failed to pass golang format checking." + echo "Please gofmt modified go files, or run './build --fmt'." + exit 1 +fi + go test -i ./http go test -v ./http