diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-12 08:35:19 -0700 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-10-12 08:35:19 -0700 |
commit | 785cc06f6ecfd9d10de58eaad8ed24ac3d24b828 (patch) | |
tree | 27a371cd2e392093a7ff10a6dfefbe0a5d85d219 | |
parent | 3461a7b20704464ee3c19a3dd31805e4c5c1fc4f (diff) | |
download | chat-785cc06f6ecfd9d10de58eaad8ed24ac3d24b828.tar.gz chat-785cc06f6ecfd9d10de58eaad8ed24ac3d24b828.tar.bz2 chat-785cc06f6ecfd9d10de58eaad8ed24ac3d24b828.zip |
Make test execution not take quadratic compilation time (#7610)
* make test execution not take quadratic compilation time
* add -p flag. we can only test one package at a time (for now)
* cd to mattermost-server for enterprise
* whoops
* let's go ahead and make the coverage profiles ready for concurrent test
-rw-r--r-- | Makefile | 36 | ||||
-rwxr-xr-x | scripts/test-xprog.sh | 9 |
2 files changed, 18 insertions, 27 deletions
@@ -1,5 +1,7 @@ .PHONY: build package run stop run-client run-server stop-client stop-server restart restart-server restart-client start-docker clean-dist clean nuke check-style check-client-style check-server-style check-unit-tests test dist setup-mac prepare-enteprise run-client-tests setup-run-client-tests cleanup-run-client-tests test-client build-linux build-osx build-windows internal-test-web-client vet run-server-for-web-client-tests +ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) + # Build Flags BUILD_NUMBER ?= $(BUILD_NUMBER:) BUILD_DATE = $(shell date -u) @@ -62,7 +64,7 @@ DIST_PATH=$(DIST_ROOT)/mattermost TESTS=. TESTFLAGS ?= -short -TESTFLAGSEE ?= -test.short +TESTFLAGSEE ?= -short # Packages lists TE_PACKAGES=$(shell go list ./... | grep -v vendor) @@ -306,39 +308,19 @@ do-cover-file: test-te: do-cover-file @echo Testing TE - - @echo "Packages to test: "$(TE_PACKAGES) - - @for package in $(TE_PACKAGES); do \ - echo "Testing "$$package; \ - $(GO) test $(GOFLAGS) -run=$(TESTS) $(TESTFLAGS) -test.v -test.timeout=2000s -covermode=count -coverprofile=cprofile.out -coverpkg=$(ALL_PACKAGES_COMMA) $$package || exit 1; \ - if [ -f cprofile.out ]; then \ - tail -n +2 cprofile.out >> cover.out; \ - rm cprofile.out; \ - fi; \ - done + find . -name 'cprofile.out' -exec sh -c 'rm "{}"' \; + $(GO) test $(GOFLAGS) -run=$(TESTS) $(TESTFLAGS) -p 1 -v -timeout=2000s -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -exec $(ROOT)/scripts/test-xprog.sh $(TE_PACKAGES) + find . -name 'cprofile.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \; test-ee: do-cover-file @echo Testing EE ifeq ($(BUILD_ENTERPRISE_READY),true) @echo "Packages to test: "$(EE_PACKAGES) - - for package in $(EE_PACKAGES); do \ - echo "Testing "$$package; \ - $(GO) test $(GOFLAGS) -run=$(TESTS) -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -c $$package || exit 1; \ - if [ -f $$(basename $$package).test ]; then \ - echo "Testing "$$package; \ - ./$$(basename $$package).test -test.v $(TESTFLAGSEE) -test.timeout=2000s -test.coverprofile=cprofile.out || exit 1; \ - if [ -f cprofile.out ]; then \ - tail -n +2 cprofile.out >> cover.out; \ - rm cprofile.out; \ - fi; \ - rm -r $$(basename $$package).test; \ - fi; \ - done - + find . -name 'cprofile.out' -exec sh -c 'rm "{}"' \; + $(GO) test $(GOFLAGS) -run=$(TESTS) $(TESTFLAGSEE) -p 1 -v -timeout=2000s -covermode=count -coverpkg=$(ALL_PACKAGES_COMMA) -exec $(ROOT)/scripts/test-xprog.sh $(EE_PACKAGES) + find . -name 'cprofile.out' -exec sh -c 'tail -n +2 {} >> cover.out ; rm "{}"' \; rm -f config/*.crt rm -f config/*.key endif diff --git a/scripts/test-xprog.sh b/scripts/test-xprog.sh new file mode 100755 index 000000000..899c95543 --- /dev/null +++ b/scripts/test-xprog.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +set -e +[[ $1 =~ (github.com.*)/_test ]] && \ + echo Testing ${BASH_REMATCH[1]} +coverprofile=`pwd`/cprofile.out +if [[ $1 == *"/enterprise/"* ]]; then + cd "$(dirname "$(dirname "${BASH_SOURCE[0]}")")" +fi +"$@" -test.coverprofile "$coverprofile" |