make/testing_flags: add LOG_TAGS, set using log envvar

The default is nolog, which prevents the unit tests in
the main pkg from being active, since otherwise they
would print as if they were being run like a dev build
of the daemon. Users can pass in custom tags when running
the Makefile by passing arguments using the log variable,
e.g. log="xxxxx xxx"".
This commit is contained in:
Conner Fromknecht 2018-09-26 02:44:25 -07:00
parent 2e489fcf24
commit 57ec03564e
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7

@ -21,6 +21,14 @@ ifneq ($(icase),)
TEST_FLAGS += -test.run=TestLightningNetworkDaemon/$(icase)
endif
# 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
# If a timeout was requested, construct initialize the proper flag for the go
# test command. If not, we set 20m (up from the default 10m).
ifneq ($(timeout),)
@ -36,12 +44,12 @@ 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)" $(TEST_FLAGS) $(UNITPKG)
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS)" $(TEST_FLAGS) -race $(UNITPKG)
UNIT := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
UNIT_RACE := $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) -race $(UNITPKG)
endif
ifeq ($(UNIT_TARGETED), no)
UNIT := $(GOLIST) | $(XARGS) $(GOTEST) -tags="$(DEV_TAGS)" $(TEST_FLAGS)
UNIT := $(GOLIST) | $(XARGS) $(GOTEST) -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
UNIT_RACE := $(UNIT) -race
endif