Skip to content

Commit

Permalink
Enable unit test
Browse files Browse the repository at this point in the history
enable unit test by uncommenting main in .prow.sh. Add test module in
Makefile. Due to the issue related to guid package microsoft/go-winio#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.
  • Loading branch information
jingxu97 committed Mar 9, 2020
1 parent 2eb1ac1 commit 6ad5c23
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 1 addition & 3 deletions .prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)'
5 changes: 3 additions & 2 deletions release-tools/prow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ configvar CSI_PROW_DEP_VERSION v0.5.1 "golang dep version to be used for vendor
# thus only makes sense in repos which provide their own CSI
# driver. Repos can enable sanity testing by setting
# CSI_PROW_TESTS_SANITY=sanity.
configvar CSI_PROW_TESTS "unit parallel serial parallel-alpha serial-alpha sanity" "tests to run"
#configvar CSI_PROW_TESTS "unit parallel serial parallel-alpha serial-alpha sanity" "tests to run"
tests_enabled () {
local t1 t2
# We want word-splitting here, so ignore: Quote to prevent word splitting, or split robustly with mapfile or read -a.
Expand Down Expand Up @@ -960,7 +960,8 @@ main () {
fi
fi
# Required for E2E testing.
run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make container || die "'make container' failed"
#Cannot build windows container on Linux node
#run_with_go "${CSI_PROW_GO_VERSION_BUILD}" make container || die "'make container' failed"
fi
if tests_need_kind; then
Expand Down

0 comments on commit 6ad5c23

Please sign in to comment.