2025-01-05 09:11:58 +02:00
|
|
|
include make/compile_flags.mk
|
|
|
|
|
|
2025-01-05 09:20:10 +02:00
|
|
|
TEST_FLAGS =
|
2025-01-05 09:22:37 +02:00
|
|
|
DEV_TAGS = dev
|
2022-10-15 09:04:04 +02:00
|
|
|
|
2025-12-05 15:06:24 +00:00
|
|
|
NUM_ITEST_TRANCHES = 8
|
|
|
|
|
ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
|
|
|
|
|
SHUFFLE_SEED = 0
|
|
|
|
|
|
|
|
|
|
# Scale the number of parallel running itest tranches.
|
|
|
|
|
ifneq ($(tranches),)
|
|
|
|
|
NUM_ITEST_TRANCHES = $(tranches)
|
|
|
|
|
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)
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Set the seed for shuffling the test cases.
|
|
|
|
|
ifneq ($(shuffleseed),)
|
|
|
|
|
SHUFFLE_SEED = $(shuffleseed)
|
|
|
|
|
endif
|
|
|
|
|
|
2022-10-15 09:04:04 +02:00
|
|
|
# Define the integration test.run filter if the icase argument was provided.
|
|
|
|
|
ifneq ($(icase),)
|
2026-01-13 23:07:19 +04:00
|
|
|
ITEST_FLAGS += -test.run="TestLightningTerminal/tranche.*/.*-of-.*/$(icase)"
|
2022-10-15 09:04:04 +02:00
|
|
|
endif
|
2025-01-05 09:11:58 +02:00
|
|
|
|
2025-01-05 12:31:05 +02:00
|
|
|
# Run itests with specified db backend.
|
|
|
|
|
ifneq ($(dbbackend),)
|
|
|
|
|
ITEST_FLAGS += -litdbbackend=$(dbbackend)
|
|
|
|
|
endif
|
|
|
|
|
|
2025-01-05 09:20:10 +02:00
|
|
|
# If a specific unit test case is being targeted, construct test.run filter.
|
|
|
|
|
ifneq ($(case),)
|
|
|
|
|
TEST_FLAGS += -test.run=$(case)
|
2025-01-05 09:24:44 +02:00
|
|
|
UNIT_TARGETED = yes
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# If specific package is being unit tested, construct the full name of the
|
|
|
|
|
# subpackage.
|
|
|
|
|
ifneq ($(pkg),)
|
|
|
|
|
UNITPKG := $(PKG)/$(pkg)
|
|
|
|
|
COVER_PKG := $(PKG)/$(pkg)
|
|
|
|
|
UNIT_TARGETED = yes
|
|
|
|
|
GOLIST = echo '$(PKG)/$(pkg)'
|
2025-01-05 09:20:10 +02:00
|
|
|
endif
|
|
|
|
|
|
2025-01-05 09:32:58 +02:00
|
|
|
# Add the build tag for running unit tests against a postgres DB.
|
|
|
|
|
ifeq ($(dbbackend),postgres)
|
|
|
|
|
DEV_TAGS += test_db_postgres
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
# Add the build tag for running unit tests against a sqlite DB.
|
|
|
|
|
ifeq ($(dbbackend),sqlite)
|
|
|
|
|
DEV_TAGS += test_db_sqlite
|
|
|
|
|
endif
|
|
|
|
|
|
2025-01-05 09:22:37 +02:00
|
|
|
# Add any additional tags that are passed in to make.
|
|
|
|
|
ifneq ($(tags),)
|
|
|
|
|
DEV_TAGS += ${tags}
|
|
|
|
|
endif
|
|
|
|
|
|
2025-01-05 09:24:44 +02:00
|
|
|
# UNIT_TARGETED 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)
|
|
|
|
|
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS) $(UNITPKG)
|
2025-03-06 19:06:02 +02:00
|
|
|
UNIT_DEBUG := $(GOTEST) -v -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS) $(UNITPKG)
|
2026-02-11 23:48:03 +01:00
|
|
|
UNIT_BENCH := $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" \
|
|
|
|
|
-test.bench=. -test.benchmem -test.run=NONE $(UNITPKG)
|
2025-01-05 09:24:44 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
ifeq ($(UNIT_TARGETED), no)
|
2025-01-05 09:22:37 +02:00
|
|
|
UNIT := $(GOLIST) | $(XARGS) env $(GOTEST) -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS)
|
2025-03-06 19:06:02 +02:00
|
|
|
UNIT_DEBUG := $(GOLIST) | $(XARGS) env $(GOTEST) -v -tags="$(DEV_TAGS) $(COMPILE_TAGS)" $(TEST_FLAGS)
|
2026-02-11 23:48:03 +01:00
|
|
|
UNIT_BENCH := $(GOLIST) | $(XARGS) env $(GOTEST) \
|
|
|
|
|
-tags="$(DEV_TAGS) $(COMPILE_TAGS)" -test.bench=. -test.benchmem \
|
|
|
|
|
-test.run=NONE
|
2025-01-05 09:24:44 +02:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
UNIT_RACE := $(UNIT) -race
|