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
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
3461a7b207
Коммит
785cc06f6e
36
Makefile
36
Makefile
@@ -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
|
||||
|
||||
9
scripts/test-xprog.sh
Исполняемый файл
9
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"
|
||||
Ссылка в новой задаче
Block a user