Gotestsum (#22826)
* disable coverage This reduces runtime of the server test suite from ~30m to ~10m, and as far as I can see: we discarded the coverage output anyway. * allow morph 60s to migrate when running tests * scripts/test.sh: drop COVERMODE Stop generating coverage data when running unit tests. It's likely we'll want this data back at some point, but for now it's unused and removing simplifies invoking tests for developers. * scripts/test.sh: remove cleanup steps * scripts/test.sh: drop TESTS parameter * scripts/test.sh: drop TESTFLAGS parameter * switch to gotestsum
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6fae1736eb
Коммит
2765d92991
@@ -54,10 +54,17 @@ ifeq ($(BUILD_NUMBER),dev)
|
||||
export MM_FEATUREFLAGS_GRAPHQL = true
|
||||
endif
|
||||
|
||||
# Ensure developer invocation and tests are anchored.
|
||||
MM_SERVER_PATH ?= $(ROOT)
|
||||
|
||||
# Go test sum configuration
|
||||
GOTESTSUM_FORMAT ?= testname
|
||||
GOTESTSUM_JUNITFILE ?= report.xml
|
||||
GOTESTSUM_JSONFILE ?= gotestsum.json
|
||||
|
||||
# mmctl
|
||||
MM_SERVER_PATH ?= $(PWD)
|
||||
MMCTL_BUILD_TAGS =
|
||||
MMCTL_TESTFLAGS = -timeout 30m -race -v
|
||||
MMCTL_TESTFLAGS = -timeout 30m -race
|
||||
MMCTL_PKG = github.com/mattermost/mattermost/server/v8/cmd/mmctl/commands
|
||||
LDFLAGS += -X "$(MMCTL_PKG).gitCommit=$(BUILD_HASH)"
|
||||
LDFLAGS += -X "$(MMCTL_PKG).gitTreeState=$(GIT_TREESTATE)"
|
||||
@@ -143,9 +150,6 @@ DIST_PATH_OSX_AMD64=$(DIST_ROOT)/osx_amd64/mattermost
|
||||
DIST_PATH_OSX_ARM64=$(DIST_ROOT)/osx_arm64/mattermost
|
||||
DIST_PATH_WIN=$(DIST_ROOT)/windows/mattermost
|
||||
|
||||
# Tests
|
||||
TESTS=.
|
||||
|
||||
# Packages lists
|
||||
TE_PACKAGES=$(shell $(GO) list ./... | grep -vE 'server/v8/cmd/mmctl')
|
||||
SUITE_PACKAGES=$(shell $(GO) list ./...| grep -vE 'server/v8/cmd/mmctl')
|
||||
@@ -431,10 +435,10 @@ endif
|
||||
check-style: plugin-checker vet golangci-lint ## Runs style/lint checks
|
||||
|
||||
|
||||
go-junit-report:
|
||||
$(GO) install github.com/jstemmer/go-junit-report@v1.0.0
|
||||
gotestsum:
|
||||
$(GO) install gotest.tools/gotestsum@v1.7.0
|
||||
|
||||
test-compile: ## Compile tests.
|
||||
test-compile: gotestsum ## Compile tests.
|
||||
@echo COMPILE TESTS
|
||||
|
||||
for package in $(SUITE_PACKAGES) $(EE_PACKAGES); do \
|
||||
@@ -451,15 +455,23 @@ modules-tidy:
|
||||
mv channels/imports/imports.go.orig channels/imports/imports.go; \
|
||||
fi;
|
||||
|
||||
test-server-pre: check-prereqs-enterprise start-docker go-junit-report ## Runs tests.
|
||||
test-server-pre: check-prereqs-enterprise start-docker gotestsum ## Runs tests.
|
||||
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
||||
@echo Running all tests
|
||||
else
|
||||
@echo Running only TE tests
|
||||
endif
|
||||
|
||||
test-server-race: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-server-race: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-server-race: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-server-race: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-server-race: test-server-pre
|
||||
./scripts/test.sh "$(GO)" "-race $(GOFLAGS)" "$(TE_PACKAGES) $(EE_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" "90m"
|
||||
ifeq ($(IS_CI),true)
|
||||
GOMAXPROCS=4 $(GOBIN)/gotestsum --packages="$(TE_PACKAGES) $(EE_PACKAGES)" -- -race $(GOFLAGS) -timeout=90m
|
||||
else
|
||||
$(GOBIN)/gotestsum --packages="$(TE_PACKAGES) $(EE_PACKAGES)" -- -race $(GOFLAGS) -timeout=90m
|
||||
endif
|
||||
ifneq ($(IS_CI),true)
|
||||
ifneq ($(MM_NO_DOCKER),true)
|
||||
ifneq ($(TEMP_DOCKER_SERVICES),)
|
||||
@@ -469,8 +481,12 @@ ifneq ($(IS_CI),true)
|
||||
endif
|
||||
endif
|
||||
|
||||
test-server: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-server: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-server: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-server: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-server: test-server-pre
|
||||
./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(SUITE_PACKAGES) $(EE_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" "90m"
|
||||
$(GOBIN)/gotestsum --packages="$(SUITE_PACKAGES) $(EE_PACKAGES)" -- $(GOFLAGS) -timeout=90m
|
||||
ifneq ($(IS_CI),true)
|
||||
ifneq ($(MM_NO_DOCKER),true)
|
||||
ifneq ($(TEMP_DOCKER_SERVICES),)
|
||||
@@ -480,17 +496,25 @@ ifneq ($(IS_CI),true)
|
||||
endif
|
||||
endif
|
||||
|
||||
test-server-ee: check-prereqs-enterprise start-docker go-junit-report ## Runs EE tests.
|
||||
test-server-ee: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-server-ee: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-server-ee: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-server-ee: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-server-ee: check-prereqs-enterprise start-docker gotestsum ## Runs EE tests.
|
||||
@echo Running only EE tests
|
||||
./scripts/test.sh "$(GO)" "$(GOFLAGS)" "$(EE_PACKAGES)" "$(TESTS)" "$(TESTFLAGS)" "$(GOBIN)" "20m"
|
||||
$(GOBIN)/gotestsum --packages="$(EE_PACKAGES)" -- $(GOFLAGS) -timeout=20m
|
||||
|
||||
test-server-quick: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-server-quick: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-server-quick: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-server-quick: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-server-quick: check-prereqs-enterprise ## Runs only quick tests.
|
||||
ifeq ($(BUILD_ENTERPRISE_READY),true)
|
||||
@echo Running all tests
|
||||
$(GO) test $(GOFLAGS) -short $(SUITE_PACKAGES) $(EE_PACKAGES)
|
||||
$(GOBIN)/gotestsum --packages="$(SUITE_PACKAGES) $(EE_PACKAGES)" -- $(GOFLAGS) -short
|
||||
else
|
||||
@echo Running only TE tests
|
||||
$(GO) test $(GOFLAGS) -short $(SUITE_PACKAGES)
|
||||
$(GOBIN)/gotestsum --packages="$(SUITE_PACKAGES)" -- $(GOFLAGS) -short
|
||||
endif
|
||||
|
||||
internal-test-web-client: ## Runs web client tests.
|
||||
@@ -530,21 +554,37 @@ inject-test-data: # add test data to the local instance.
|
||||
@echo Login with a regular account username=user-1 password=SampleUs@r-1
|
||||
@echo ========================================================================
|
||||
|
||||
test-mmctl-unit:
|
||||
test-mmctl-unit: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-mmctl-unit: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-mmctl-unit: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-mmctl-unit: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-mmctl-unit: gotestsum
|
||||
@echo Running mmctl unit tests
|
||||
$(GO) test $(MMCTL_TESTFLAGS) -tags 'unit $(MMCTL_BUILD_TAGS)' $(MMCTL_PACKAGES)
|
||||
$(GOBIN)/gotestsum --packages="$(MMCTL_PACKAGES)" -- -tags 'unit $(MMCTL_BUILD_TAGS)' $(MMCTL_TESTFLAGS)
|
||||
|
||||
test-mmctl-e2e: start-docker
|
||||
test-mmctl-e2e: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-mmctl-e2e: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-mmctl-e2e: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-mmctl-e2e: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-mmctl-e2e: gotestsum start-docker
|
||||
@echo Running mmctl e2e tests
|
||||
MM_SERVER_PATH=$(MM_SERVER_PATH) $(GO) test $(MMCTL_TESTFLAGS) -tags 'e2e $(MMCTL_BUILD_TAGS)' $(MMCTL_PACKAGES)
|
||||
$(GOBIN)/gotestsum --packages="$(MMCTL_PACKAGES)" -- -tags 'e2e $(MMCTL_BUILD_TAGS)' $(MMCTL_TESTFLAGS)
|
||||
|
||||
test-mmctl: start-docker
|
||||
test-mmctl: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-mmctl-e2e: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-mmctl-e2e: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-mmctl-e2e: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-mmctl: gotestsum start-docker
|
||||
@echo Running all mmctl tests
|
||||
MM_SERVER_PATH=$(MM_SERVER_PATH) $(GO) test $(MMCTL_TESTFLAGS) -tags 'unit e2e $(MMCTL_BUILD_TAGS)' $(MMCTL_PACKAGES)
|
||||
$(GOBIN)/gotestsum --packages="$(MMCTL_PACKAGES)" -- -tags 'unit e2e $(MMCTL_BUILD_TAGS)' $(MMCTL_TESTFLAGS)
|
||||
|
||||
test-mmctl-coverage: start-docker
|
||||
test-mmctl-coverage: export MM_SERVER_PATH := $(MM_SERVER_PATH)
|
||||
test-mmctl-e2e: export GOTESTSUM_FORMAT := $(GOTESTSUM_FORMAT)
|
||||
test-mmctl-e2e: export GOTESTSUM_JUNITFILE := $(GOTESTSUM_JUNITFILE)
|
||||
test-mmctl-e2e: export GOTESTSUM_JSONFILE := $(GOTESTSUM_JSONFILE)
|
||||
test-mmctl-coverage: gotestsum start-docker
|
||||
@echo Running all mmctl tests with coverage
|
||||
MM_SERVER_PATH=$(MM_SERVER_PATH) $(GO) test $(MMCTL_TESTFLAGS) -tags 'unit e2e $(MMCTL_BUILD_TAGS)' -coverprofile=mmctlcover.out $(MMCTL_PACKAGES)
|
||||
$(GOBIN)/gotestsum --packages="$(MMCTL_PACKAGES)" -- -tags 'unit e2e $(MMCTL_BUILD_TAGS)' -coverprofile=mmctlcover.out $(MMCTL_TESTFLAGS)
|
||||
$(GO) tool cover -html=mmctlcover.out
|
||||
|
||||
validate-go-version: ## Validates the installed version of go against Mattermost's minimum requirement.
|
||||
|
||||
Ссылка в новой задаче
Block a user