Skip to content

Commit

Permalink
Further refinement of test.sh
Browse files Browse the repository at this point in the history
* Update to test on go1.9.2
* Ensure flag from tip doesn't break build
  • Loading branch information
trevrosen committed Nov 6, 2017
1 parent 98d68d8 commit f5b5632
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ dist: trusty
go_import_path: gobot.io/x/gobot
go:
- 1.8.4
- 1.9.1
- 1.9.2
- tip
matrix:
allow_failures:
Expand Down
3 changes: 1 addition & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ fmt_check:

# Test and generate coverage
test_with_coverage:
./ci/test.sh
exit $$?
./ci/test.sh || exit 1

deps:
ifeq (,$(shell which dep))
Expand Down
17 changes: 12 additions & 5 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
## Only uncomment the below for debugging
#set -euxo pipefail

LOCAL_GO_VERSION=$(go version | awk -F' ' '{print $3}' | tr -d '[:space:]')
GO_VERSION="${TRAVIS_GO_VERSION:=$LOCAL_GO_VERSION}"
TIP_VERSION_IDENTIFIER="tip"
echo $GO_VERSION

# Hold the package names that contain failures
FAIL_PACKAGES=()

Expand All @@ -16,11 +21,13 @@ pushd $PWD/..

# Iterate over all non-vendor packages and run tests with coverage
for package in $EXCLUDING_VENDOR; do \
result=$(go test -covermode=count -coverprofile=tmp.cov $package)
# If a `go test` command has failures, it will exit 1
# a go vet check should exit 2 (https://github.com/golang/go/blob/master/src/cmd/vet/all/main.go#L58)
# `go test` contains `vet` was introduced in this Change https://go-review.googlesource.com/c/go/+/74356
if [ $? -eq 1 ]; then
if [ $GO_VERSION == $TIP_VERSION_IDENTIFIER ]; then
# `go test` runs a vet subset as of this Change https://go-review.googlesource.com/c/go/+/74356
result=$(go test -vet=off -covermode=count -coverprofile=tmp.cov $package)
else
result=$(go test -covermode=count -coverprofile=tmp.cov $package)
fi
if [ $? -ne 0 ]; then
FAIL_PACKAGES+=($package);
fi;
echo "$result"
Expand Down

0 comments on commit f5b5632

Please sign in to comment.