From ce46642aa04ba444aceae6c41fd3b76ee1056034 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Wed, 30 Aug 2017 20:31:17 +0200 Subject: [PATCH] Move counter cli tests into example dir --- Makefile | 9 ++++++--- examples/counter/Makefile | 14 ++++++++++++++ {tests => examples/counter/tests}/cli/counter.sh | 8 ++++++-- 3 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 examples/counter/Makefile rename {tests => examples/counter/tests}/cli/counter.sh (96%) diff --git a/Makefile b/Makefile index 7666ae6486..3d1174c754 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ GOTOOLS = github.com/mitchellh/gox \ TUTORIALS=$(shell find docs/guide -name "*md" -type f) EXAMPLES := counter +EXAMPLE_DIRS := $(addprefix ./examples/,${EXAMPLES}) LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`" @@ -14,8 +15,8 @@ build: install: @go install -ldflags $(LINKER_FLAGS) ./cmd/... - @for EX in $(EXAMPLES); do \ - go install -ldflags $(LINKER_FLAGS) ./examples/$$EX/cmd/...; \ + @for EX in $(EXAMPLE_DIRS); do \ + cd $$EX && make install; \ done dist: @@ -40,10 +41,12 @@ test_cli: tests/cli/shunit2 ./tests/cli/basictx.sh ./tests/cli/eyes.sh ./tests/cli/roles.sh - ./tests/cli/counter.sh ./tests/cli/restart.sh ./tests/cli/rest.sh ./tests/cli/ibc.sh + @for EX in $(EXAMPLE_DIRS); do \ + cd $$EX && make test_cli; \ + done test_tutorial: docs/guide/shunit2 @shelldown ${TUTORIALS} diff --git a/examples/counter/Makefile b/examples/counter/Makefile new file mode 100644 index 0000000000..9fd61be897 --- /dev/null +++ b/examples/counter/Makefile @@ -0,0 +1,14 @@ +LINKER_FLAGS:="-X github.com/cosmos/cosmos-sdk/client/commands.CommitHash=`git rev-parse --short HEAD`" + +install: + @go install -ldflags $(LINKER_FLAGS) ./cmd/... + +test: test_unit test_cli + +test_unit: + @go test `glide novendor` + +test_cli: + ./tests/cli/counter.sh + +.PHONY: install test test_unit test_cli diff --git a/tests/cli/counter.sh b/examples/counter/tests/cli/counter.sh similarity index 96% rename from tests/cli/counter.sh rename to examples/counter/tests/cli/counter.sh index f57827a963..ad9f994e57 100755 --- a/tests/cli/counter.sh +++ b/examples/counter/tests/cli/counter.sh @@ -112,5 +112,9 @@ test03AddCount() { # Load common then run these tests with shunit2! DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" #get this files directory -. $DIR/common.sh -. $DIR/shunit2 + +# TODO: how to handle this if we are not in the same directory +CLI_DIR=${DIR}/../../../../tests/cli + +. $CLI_DIR/common.sh +. $CLI_DIR/shunit2