Skip to content

Commit

Permalink
Makefile: Add Go test for schema-go
Browse files Browse the repository at this point in the history
And run them from Travis.

Also replace some old Travis test commands with a single call to 'make
test'.  Now we die on the first error (e.g. we don't run the Go tests
if lint fails), but I don't think that's a big problem, and this way
we don't have to maintain two parallel lists of test targets.

Signed-off-by: W. Trevor King <wking@tremily.us>
  • Loading branch information
wking committed May 11, 2017
1 parent 527ebbd commit 43e7369
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ install: true

script:
- env | grep TRAVIS_
- make .govet
- make .golint
- echo "${TRAVIS_COMMIT_RANGE} -> ${TRAVIS_COMMIT_RANGE/.../..} (travis-ci/travis-ci#4596)"
- TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" make .gitvalidation
- TRAVIS_COMMIT_RANGE="${TRAVIS_COMMIT_RANGE/.../..}" make test
- make docs
- make -C schema test
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,14 @@ HOST_GOLANG_VERSION = $(shell go version | cut -d ' ' -f3 | cut -c 3-)
# this variable is used like a function. First arg is the minimum version, Second arg is the version to be checked.
ALLOWED_GO_VERSION = $(shell test '$(shell /bin/echo -e "$(1)\n$(2)" | sort -V | head -n1)' = '$(1)' && echo 'true')

test: .govet .golint .gitvalidation
TESTS := .govet .golint .gitvalidation

# (*testing.T).Run is new in 1.7, https://golang.org/doc/go1.7#testing
ifeq ($(call ALLOWED_GO_VERSION,1.7,$(HOST_GOLANG_VERSION)),true)
TESTS += .specs-go
endif

test: $(TESTS)

.govet:
go vet -x ./...
Expand All @@ -77,7 +84,10 @@ else
git-validation -v -run DCO,short-subject,dangling-whitespace -range $(EPOCH_TEST_COMMIT)..HEAD
endif

install.tools: .install.golint .install.gitvalidation
.specs-go:
go test ./specs-go

install.tools: .install.golint .install.gitvalidation .install.canonicaljson

# golint does not even build for <go1.6
.install.golint:
Expand All @@ -88,6 +98,9 @@ endif
.install.gitvalidation:
go get -u github.com/vbatts/git-validation

.install.canonicaljson:
go get -d -u github.com/docker/go/canonical/json

clean:
rm -rf $(OUTPUT_DIRNAME) *~
rm -f version.md
Expand Down

0 comments on commit 43e7369

Please sign in to comment.