2018-09-20 13:27:57 +03:00
|
|
|
DEV_TAGS = dev
|
|
|
|
LOG_TAGS =
|
2018-03-29 15:11:31 +03:00
|
|
|
TEST_FLAGS =
|
2019-05-21 13:33:07 +03:00
|
|
|
COVER_PKG = $$(go list ./... | grep -v lnrpc)
|
2018-03-29 15:11:31 +03:00
|
|
|
|
|
|
|
# If specific package is being unit tested, construct the full name of the
|
|
|
|
# subpackage.
|
|
|
|
ifneq ($(pkg),)
|
|
|
|
UNITPKG := $(PKG)/$(pkg)
|
|
|
|
UNIT_TARGETED = yes
|
2019-05-21 13:33:07 +03:00
|
|
|
COVER_PKG = $(PKG)/$(pkg)
|
2018-03-29 15:11:31 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# If a specific unit test case is being target, construct test.run filter.
|
|
|
|
ifneq ($(case),)
|
|
|
|
TEST_FLAGS += -test.run=$(case)
|
|
|
|
UNIT_TARGETED = yes
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Define the integration test.run filter if the icase argument was provided.
|
|
|
|
ifneq ($(icase),)
|
|
|
|
TEST_FLAGS += -test.run=TestLightningNetworkDaemon/$(icase)
|
|
|
|
endif
|
|
|
|
|
2018-09-26 12:44:25 +03:00
|
|
|
# Define the log tags that will be applied only when running unit tests. If none
|
|
|
|
# are provided, we default to "nolog" which will be silent.
|
|
|
|
ifneq ($(log),)
|
|
|
|
LOG_TAGS := ${log}
|
|
|
|
else
|
|
|
|
LOG_TAGS := nolog
|
|
|
|
endif
|
|
|
|
|
2018-03-29 15:11:31 +03:00
|
|
|
# If a timeout was requested, construct initialize the proper flag for the go
|
2018-07-23 18:10:21 +03:00
|
|
|
# test command. If not, we set 20m (up from the default 10m).
|
2018-03-29 15:11:31 +03:00
|
|
|
ifneq ($(timeout),)
|
|
|
|
TEST_FLAGS += -test.timeout=$(timeout)
|
2018-07-23 18:10:21 +03:00
|
|
|
else
|
2019-05-24 15:17:49 +03:00
|
|
|
TEST_FLAGS += -test.timeout=40m
|
2018-03-29 15:11:31 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# UNIT_TARGTED is undefined iff a specific package and/or unit test case is
|
|
|
|
# not being targeted.
|
|
|
|
UNIT_TARGETED ?= no
|
|
|
|
|
|
|
|
# If a specific package/test case was requested, run the unit test for the
|
|
|
|
# targeted case. Otherwise, default to running all tests.
|
|
|
|
ifeq ($(UNIT_TARGETED), yes)
|
2018-09-26 12:44:25 +03:00
|
|
|
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
|
|
|
|
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) -race $(UNITPKG)
|
2018-03-29 15:11:31 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(UNIT_TARGETED), no)
|
2018-11-30 07:05:32 +03:00
|
|
|
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
|
2018-04-29 14:38:59 +03:00
|
|
|
UNIT_RACE := $(UNIT) -race
|
2018-03-29 15:11:31 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
# Construct the integration test command with the added build flags.
|
2019-06-21 02:55:13 +03:00
|
|
|
ITEST_TAGS := $(DEV_TAGS) rpctest chainrpc walletrpc signrpc invoicesrpc autopilotrpc routerrpc watchtowerrpc
|
2019-05-24 15:17:48 +03:00
|
|
|
|
|
|
|
# Default to btcd backend if not set.
|
|
|
|
ifneq ($(backend),)
|
|
|
|
ITEST_TAGS += ${backend}
|
|
|
|
else
|
|
|
|
ITEST_TAGS += btcd
|
|
|
|
endif
|
|
|
|
|
2019-06-12 17:44:21 +03:00
|
|
|
ITEST := rm lntest/itest/output*.log; date; $(GOTEST) ./lntest/itest -tags="$(ITEST_TAGS)" $(TEST_FLAGS) -logoutput
|