From 805ade7d34cf67001b5a6d38bc1d7bbca01ca20a Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Wed, 6 Dec 2017 13:30:31 -0600 Subject: [PATCH] Makes tests on travis not run in verbose mode. --- GNUmakefile | 24 +++++++++++++++--------- scripts/test_check.sh | 10 ++++++++++ 2 files changed, 25 insertions(+), 9 deletions(-) create mode 100755 scripts/test_check.sh diff --git a/GNUmakefile b/GNUmakefile index bcdb9ffeb..a4e304b6d 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,3 +1,4 @@ + SHELL = bash PROJECT_ROOT := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))) THIS_OS := $(shell uname) @@ -22,6 +23,15 @@ ifeq (0,$(shell pkg-config --exists lxc; echo $$?)) HAS_LXC="true" endif +ifeq ($(TRAVIS),true) +$(info Running in Travis, verbose mode is disabled) +else +VERBOSE="true" +endif + +print-% : ; @echo $* = $($*) + + ALL_TARGETS += linux_386 \ linux_amd64 \ linux_arm \ @@ -227,17 +237,13 @@ test: ## Run the Nomad test suite and/or the Nomad UI test suite test-nomad: dev ## Run Nomad test suites @echo "==> Running Nomad test suites:" @NOMAD_TEST_RKT=1 \ - go test \ - -v \ + go test $(if $(VERBOSE),-v) \ -cover \ -timeout=900s \ - -tags="nomad_test $(if $(HAS_LXC),lxc)" ./... >test.log ; echo $$? > exit-code - @echo "Exit code: $$(cat exit-code)" >> test.log - @grep -A1 -- '--- FAIL:' test.log || true - @grep '^FAIL' test.log || true - @grep -A10 'panic' test.log || true - @test "$$TRAVIS" == "true" && cat test.log || true - @if [ "$$(cat exit-code)" == "0" ] ; then echo "PASS" ; exit 0 ; else exit 1 ; fi + -tags="nomad_test $(if $(HAS_LXC),lxc)" ./... $(if $(VERBOSE), >test.log ; echo $$? > exit-code) + @if [ $(VERBOSE) ] ; then \ + bash -C "$(PROJECT_ROOT)/scripts/test_check.sh" ; \ + fi .PHONY: clean clean: GOPATH=$(shell go env GOPATH) diff --git a/scripts/test_check.sh b/scripts/test_check.sh new file mode 100755 index 000000000..4110f5c89 --- /dev/null +++ b/scripts/test_check.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +echo "Exit code: $(cat exit-code)" >> test.log; +grep -A10 'panic: test timed out' test.log || true; +grep -A1 -- '--- SKIP:' test.log || true; +grep -A1 -- '--- FAIL:' test.log || true; +grep '^FAIL' test.log || true; +exit_code=`cat exit-code` +echo $exit_code +if [ ${exit_code} == "0" ]; then echo "PASS" ; exit 0 ; else echo "TESTS FAILED"; exit 1 ; fi +