From fb612e5a7b83b8a008ed813974c452726b4a1da9 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 27 Nov 2017 19:52:06 +0000 Subject: [PATCH] fixup tests --- Makefile | 14 ++++++++++---- circle.yml | 2 +- cmd/abci-cli/abci-cli.go | 4 ++-- cmd/abci-cli/main.go | 11 ++++++++++- test.sh | 10 +++++----- tests/test_app/app.go | 2 +- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 57ab4052..ab9223f6 100644 --- a/Makefile +++ b/Makefile @@ -36,12 +36,18 @@ dist: @ bash scripts/publish.sh # test.sh requires that we run the installed cmds, must not be out of date -test: install +test: @ find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \; - @ echo "==> Running unit tests" + @ echo "==> Running go test" @ go test $(PACKAGES) - @ echo "==> Running integration tests (./tests)" - @ bash tests/test.sh + +test_race: + @ find . -path ./vendor -prune -o -name "*.sock" -exec rm {} \; + @ echo "==> Running go test --race" + @go test -v -race $(PACKAGES) + +test_integrations: + @ bash test.sh fmt: @ go fmt ./... diff --git a/circle.yml b/circle.yml index 45987363..c6904fae 100644 --- a/circle.yml +++ b/circle.yml @@ -16,7 +16,7 @@ checkout: test: override: - - cd $REPO && make get_vendor_deps && make metalinter_test && bash ./test.sh + - cd $REPO && make get_vendor_deps && make metalinter_test && make test_integrations post: - cd "$REPO" && bash <(curl -s https://codecov.io/bash) -f coverage.txt - cd "$REPO" && mv coverage.txt "${CIRCLE_ARTIFACTS}" diff --git a/cmd/abci-cli/abci-cli.go b/cmd/abci-cli/abci-cli.go index d27bf24b..d6e95d96 100644 --- a/cmd/abci-cli/abci-cli.go +++ b/cmd/abci-cli/abci-cli.go @@ -96,10 +96,10 @@ var RootCmd = &cobra.Command{ }, } -func Execute() { +func Execute() error { addGlobalFlags() addCommands() - RootCmd.Execute() + return RootCmd.Execute() } func addGlobalFlags() { diff --git a/cmd/abci-cli/main.go b/cmd/abci-cli/main.go index 736ef310..a927e7ed 100644 --- a/cmd/abci-cli/main.go +++ b/cmd/abci-cli/main.go @@ -1,5 +1,14 @@ package main +import ( + "fmt" + "os" +) + func main() { - Execute() + err := Execute() + if err != nil { + fmt.Print(err) + os.Exit(1) + } } diff --git a/test.sh b/test.sh index 136f60e2..33839c06 100755 --- a/test.sh +++ b/test.sh @@ -5,11 +5,11 @@ echo "" > coverage.txt echo "==> Running unit tests" for d in $(go list ./... | grep -v vendor); do - go test -race -coverprofile=profile.out -covermode=atomic "$d" - if [ -f profile.out ]; then - cat profile.out >> coverage.txt - rm profile.out - fi + go test -race -coverprofile=profile.out -covermode=atomic "$d" + if [ -f profile.out ]; then + cat profile.out >> coverage.txt + rm profile.out + fi done echo "==> Running integration tests (./tests)" diff --git a/tests/test_app/app.go b/tests/test_app/app.go index c869fe83..59d7aec4 100644 --- a/tests/test_app/app.go +++ b/tests/test_app/app.go @@ -48,7 +48,7 @@ func startClient(abciType string) abcicli.Client { } func setOption(client abcicli.Client, key, value string) { - _, err := client.SetOptionSync(key, value) + _, err := client.SetOptionSync(types.RequestSetOption{key, value}) if err != nil { panicf("setting %v=%v: \nerr: %v", key, value, err) }