2018-09-20 13:27:57 +03:00
|
|
|
DEV_TAGS = dev
|
2020-06-16 15:41:34 +03:00
|
|
|
RPC_TAGS = autopilotrpc chainrpc invoicesrpc routerrpc signrpc verrpc walletrpc watchtowerrpc wtclientrpc
|
2018-09-20 13:27:57 +03:00
|
|
|
LOG_TAGS =
|
2018-03-29 15:11:31 +03:00
|
|
|
TEST_FLAGS =
|
2020-06-22 20:36:48 +03:00
|
|
|
ITEST_FLAGS =
|
2020-12-03 13:30:26 +03:00
|
|
|
EXEC_SUFFIX =
|
2020-12-11 09:08:44 +03:00
|
|
|
COVER_PKG = $$(go list -deps -tags="$(DEV_TAGS)" ./... | grep '$(PKG)' | grep -v lnrpc)
|
2020-12-08 18:27:00 +03:00
|
|
|
NUM_ITEST_TRANCHES = 4
|
2020-11-07 15:23:30 +03:00
|
|
|
ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
|
2018-03-29 15:11:31 +03:00
|
|
|
|
2020-06-16 15:41:34 +03:00
|
|
|
# If rpc option is set also add all extra RPC tags to DEV_TAGS
|
|
|
|
ifneq ($(with-rpc),)
|
|
|
|
DEV_TAGS += $(RPC_TAGS)
|
|
|
|
endif
|
|
|
|
|
2020-11-04 13:03:33 +03:00
|
|
|
# Scale the number of parallel running itest tranches.
|
|
|
|
ifneq ($(tranches),)
|
|
|
|
NUM_ITEST_TRANCHES = $(tranches)
|
2020-11-07 15:23:30 +03:00
|
|
|
ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Give the ability to run the same tranche multiple times at the same time.
|
|
|
|
ifneq ($(parallel),)
|
|
|
|
ITEST_PARALLELISM = $(parallel)
|
2020-11-04 13:03:33 +03:00
|
|
|
endif
|
|
|
|
|
2020-12-03 13:30:26 +03:00
|
|
|
# Windows needs to append a .exe suffix to all executable files, otherwise it
|
|
|
|
# won't run them.
|
|
|
|
ifneq ($(windows),)
|
|
|
|
EXEC_SUFFIX = .exe
|
|
|
|
endif
|
|
|
|
|
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),)
|
2020-11-04 13:03:33 +03:00
|
|
|
TEST_FLAGS += -test.run="TestLightningNetworkDaemon/.*-of-.*/.*/$(icase)"
|
2018-03-29 15:11:31 +03:00
|
|
|
endif
|
|
|
|
|
2020-06-22 20:36:48 +03:00
|
|
|
# Run itests with etcd backend.
|
|
|
|
ifeq ($(etcd),1)
|
|
|
|
ITEST_FLAGS += -etcd
|
|
|
|
DEV_TAGS += kvdb_etcd
|
|
|
|
endif
|
|
|
|
|
2020-09-04 16:49:53 +03:00
|
|
|
ifneq ($(tags),)
|
|
|
|
DEV_TAGS += ${tags}
|
|
|
|
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
|
2021-04-29 02:25:22 +03:00
|
|
|
# test command. If not, we set 60m (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
|
2021-04-29 02:25:22 +03:00
|
|
|
TEST_FLAGS += -test.timeout=60m
|
2018-03-29 15:11:31 +03:00
|
|
|
endif
|
|
|
|
|
2020-09-04 16:49:53 +03:00
|
|
|
GOLIST := go list -tags="$(DEV_TAGS)" -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
|
|
|
|
GOLISTCOVER := $(shell go list -tags="$(DEV_TAGS)" -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
|
|
|
|
|
2018-03-29 15:11:31 +03:00
|
|
|
# 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)
|
2021-02-17 19:47:14 +03:00
|
|
|
UNIT_DEBUG := $(GOTEST) -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
|
2020-12-11 02:05:22 +03:00
|
|
|
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS) lowscrypt" $(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)
|
2021-02-17 19:47:14 +03:00
|
|
|
UNIT_DEBUG := $(GOLIST) | $(XARGS) env $(GOTEST) -v -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
|
|
|
|
|
|
|
|
|
2019-05-24 15:17:48 +03:00
|
|
|
# Default to btcd backend if not set.
|
2019-09-18 13:58:18 +03:00
|
|
|
ifeq ($(backend),)
|
|
|
|
backend = btcd
|
2019-05-24 15:17:48 +03:00
|
|
|
endif
|
|
|
|
|
2019-09-18 13:58:18 +03:00
|
|
|
# Construct the integration test command with the added build flags.
|
2020-06-16 15:41:34 +03:00
|
|
|
ITEST_TAGS := $(DEV_TAGS) $(RPC_TAGS) rpctest $(backend)
|