From 80778397987efe128c62e524b0da931685ccea9f Mon Sep 17 00:00:00 2001 From: Jing Xu Date: Fri, 17 Jan 2020 16:22:10 -0800 Subject: [PATCH] Enable unit test enable unit test by uncommenting main in .prow.sh. Add test module in Makefile. Due to the issue related to guid package https://github.com/microsoft/go-winio/pull/169 which causes errors when running unit tests on Linux, the current solution is to add some filter for the test path. Will update it after the issue is resolved. --- .prow.sh | 4 +--- Makefile | 11 ++++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.prow.sh b/.prow.sh index e67318f8..73c70af2 100755 --- a/.prow.sh +++ b/.prow.sh @@ -7,6 +7,4 @@ . release-tools/prow.sh -# TODO: Once we add windows build rules and a Makefile, we can enable -# some basic unit testing -# main +main diff --git a/Makefile b/Makefile index da451ad5..4206a954 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,9 @@ BUILD_TOOLS_DIR = $(BUILD_DIR)/tools GO_ENV_VARS = GO111MODULE=on GOOS=windows +# TODO: temporarily disable generate and lint because they are not working. .PHONY: all -all: generate compile lint +all: compile test .PHONY: compile compile: compile-client compile-server compile-csi-proxy-api-gen @@ -74,6 +75,14 @@ lint: $(GOLANGCI_LINT) $(GO_ENV_VARS) $(GOLANGCI_LINT) run git --no-pager diff --exit-code +.PHONY: test-go +test: test-go +test-go: + @ echo; echo "### $@:" + # TODO: After issue https://github.com/microsoft/go-winio/pull/169 is resolved, remove the filter on the test path. + GO111MODULE=on go test `find ./internal/server/ -type d -not -name server`;\ + cd client && GO111MODULE=on go test `go list ./... | grep -v group` && cd ../ + # see https://github.com/golangci/golangci-lint#binary-release $(GOLANGCI_LINT): curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$$(dirname '$(GOLANGCI_LINT)')" '$(GOLANGCI_LINT_VERSION)'