Skip to content

Commit

Permalink
move testing to Makefile
Browse files Browse the repository at this point in the history
The tests previously defined only for Travis CI are now invoked with
"make test".

e2e.sh assumed that the binaries are in the regular search path. This
is no longer necessary and in addition, mock is no longer placed in
the developers $GOPATH/bin by the script.
  • Loading branch information
pohly committed Jul 13, 2018
1 parent d34fca7 commit e2e872d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
5 changes: 1 addition & 4 deletions .travis.yml
Expand Up @@ -3,10 +3,7 @@ matrix:
include:
- go: 1.10.3
script:
- go fmt $(go list ./... | grep -v vendor) | wc -l | grep 0
- go vet $(go list ./... | grep -v vendor)
- go test $(go list ./... | grep -v vendor | grep -v "cmd/csi-sanity")
- ./hack/e2e.sh
- make test
after_success:
- if [ "${TRAVIS_BRANCH}" == "master" ] && [ "${TRAVIS_PULL_REQUEST}" == "false" ]; then
docker login -u "${DOCKER_USERNAME}" -p "${DOCKER_PASSWORD}" quay.io;
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Expand Up @@ -38,5 +38,14 @@ container: $(APP)
push: container
docker push $(IMAGE_NAME):$(IMAGE_VERSION)

.PHONY: all clean container push

test:
if ! [ $$(go fmt $$(go list ./... | grep -v vendor) | wc -l) -eq 0 ]; then \
echo "formatting errors:"; \
go fmt $$(go list ./... | grep -v vendor); \
false; \
fi
go vet $$(go list ./... | grep -v vendor)
go test $$(go list ./... | grep -v vendor | grep -v "cmd/csi-sanity")
./hack/e2e.sh

.PHONY: all clean container push test
10 changes: 5 additions & 5 deletions hack/e2e.sh
Expand Up @@ -11,10 +11,10 @@ CSI_MOCK_VERSION="master"
# See https://github.com/grpc/grpc/blob/master/doc/naming.md
runTest()
{
CSI_ENDPOINT=$1 mock &
CSI_ENDPOINT=$1 ./bin/mock &
local pid=$!

csi-sanity $TESTARGS --csi.endpoint=$2; ret=$?
./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$2; ret=$?
kill -9 $pid

if [ $ret -ne 0 ] ; then
Expand All @@ -24,18 +24,18 @@ runTest()

runTestWithCreds()
{
CSI_ENDPOINT=$1 CSI_ENABLE_CREDS=true mock &
CSI_ENDPOINT=$1 CSI_ENABLE_CREDS=true ./bin/mock &
local pid=$!

csi-sanity $TESTARGS --csi.endpoint=$2 --csi.secrets=mock/mocksecret.yaml; ret=$?
./cmd/csi-sanity/csi-sanity $TESTARGS --csi.endpoint=$2 --csi.secrets=mock/mocksecret.yaml; ret=$?
kill -9 $pid

if [ $ret -ne 0 ] ; then
exit $ret
fi
}

go install ./mock || exit 1
go build -o bin/mock ./mock || exit 1

cd cmd/csi-sanity
make clean install || exit 1
Expand Down

0 comments on commit e2e872d

Please sign in to comment.