github.com/coreos/rocket@v1.30.1-0.20200224141603-171c416fac02/tests/tests.mk (about)

     1  $(call setup-stamp-file,TST_SHORT_TESTS_STAMP,/short-tests)
     2  
     3  GO_RACE := $(if $(call equal,$(GOARCH),amd64),--race,)
     4  
     5  # gofmt takes list of directories
     6  # go vet and go test take a list of packages
     7  $(call forward-vars,$(TST_SHORT_TESTS_STAMP), \
     8  	GOFMT GO_ENV GO RKT_TAGS)
     9  $(TST_SHORT_TESTS_STAMP):
    10  	$(eval TST_DIRS_WITH_GOFILES := $(call go-find-directories,$(GO_TEST_PACKAGES),GoFiles))
    11  	$(eval TST_DIRS_WITH_TESTGOFILES := $(call go-find-directories,$(GO_TEST_PACKAGES),TestGoFiles XTestGoFiles,tests))
    12  	$(eval TST_GOFMT_DIRS := $(foreach d,$(TST_DIRS_WITH_GOFILES),./$d))
    13  	$(eval TST_GO_VET_PACKAGES := $(foreach d,$(TST_DIRS_WITH_GOFILES),$(REPO_PATH)/$d))
    14  	$(eval TST_GO_TEST_PACKAGES := $(foreach d,$(TST_DIRS_WITH_TESTGOFILES),$(REPO_PATH)/$d))
    15  	$(VQ) \
    16  	set -e; \
    17  	$(call vb,vt,GOFMT,$(TST_GOFMT_DIRS)) \
    18  	res=$$($(GOFMT) -s -l $(TST_GOFMT_DIRS)); \
    19  	if [ -n "$${res}" ]; then echo -e "gofmt checking failed:\n$${res}"; exit 1; fi; \
    20  	$(call vb,vt,GO VET,$(TST_GO_VET_PACKAGES)) \
    21  	res=$$($(GO_ENV) "$(GO)" vet $(TST_GO_VET_PACKAGES)); \
    22  	if [ -n "$${res}" ]; then echo -e "govet checking failed:\n$${res}"; exit 1; fi; \
    23  	$(call vb,vt,(C) CHECK) \
    24  	res=$$( \
    25  		for file in $$(find . -type f -iname '*.go' ! -path './vendor/*'); do \
    26  			head -n1 "$${file}" | grep -Eq "(Copyright|generated)" || echo -e "  $${file}"; \
    27  		done; \
    28  	); \
    29  	if [ -n "$${res}" ]; then echo -e "license header checking failed:\n$${res}"; exit 1; fi; \
    30  	$(call vb,vt,GO TEST,$(TST_GO_TEST_PACKAGES)) \
    31  	$(GO_ENV) "$(GO)" test -timeout 60s -cover $(RKT_TAGS) $(TST_GO_TEST_PACKAGES) $(GO_RACE)
    32  
    33  TOPLEVEL_CHECK_STAMPS += $(TST_SHORT_TESTS_STAMP)
    34  TOPLEVEL_UNIT_CHECK_STAMPS += $(TST_SHORT_TESTS_STAMP)
    35  
    36  ifeq ($(RKT_RUN_FUNCTIONAL_TESTS),yes)
    37  
    38  $(call inc-one,functional.mk)
    39  
    40  else
    41  
    42  $(call setup-stamp-file,TST_FUNC_TESTS_DISABLED_STAMP,/func-test-disabled)
    43  
    44  TOPLEVEL_FUNCTIONAL_CHECK_STAMPS += $(TST_FUNC_TESTS_DISABLED_STAMP)
    45  
    46  $(TST_FUNC_TESTS_DISABLED_STAMP):
    47  	$(VQ) \
    48  	echo 'Functional tests are disabled, pass --enable-functional-tests to configure script to enable them.' >&2; \
    49  	false
    50  
    51  endif
    52  
    53  $(call undefine-namespaces,TST)