github.com/decred/dcrlnd@v0.7.6/make/testing_flags.mk (about)

     1  DEV_TAGS = dev
     2  LOG_TAGS =
     3  UTEST_TAGS = unittest
     4  TEST_FLAGS =
     5  RACE_ENV = CGO_ENABLED=1 GORACE="history_size=7 halt_on_errors=1"
     6  ITEST_FLAGS =
     7  EXEC_SUFFIX =
     8  COVER_PKG = $$(go list -deps -tags="$(DEV_TAGS)" ./... | grep '$(PKG)' | grep -v lnrpc)
     9  NUM_ITEST_TRANCHES = 4
    10  ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
    11  POSTGRES_START_DELAY = 5
    12  
    13  # If rpc option is set also add all extra RPC tags to DEV_TAGS
    14  ifneq ($(with-rpc),)
    15  DEV_TAGS += $(RPC_TAGS)
    16  endif
    17  
    18  # Scale the number of parallel running itest tranches.
    19  ifneq ($(tranches),)
    20  NUM_ITEST_TRANCHES = $(tranches)
    21  ITEST_PARALLELISM = $(NUM_ITEST_TRANCHES)
    22  endif
    23  
    24  # Give the ability to run the same tranche multiple times at the same time.
    25  ifneq ($(parallel),)
    26  ITEST_PARALLELISM = $(parallel)
    27  endif
    28  
    29  # Windows needs to append a .exe suffix to all executable files, otherwise it
    30  # won't run them.
    31  ifneq ($(windows),)
    32  EXEC_SUFFIX = .exe
    33  endif
    34  
    35  # If specific package is being unit tested, construct the full name of the
    36  # subpackage.
    37  ifneq ($(pkg),)
    38  UNITPKG := $(PKG)/$(pkg)
    39  UNIT_TARGETED = yes
    40  COVER_PKG = $(PKG)/$(pkg)
    41  endif
    42  
    43  # If a specific unit test case is being target, construct test.run filter.
    44  ifneq ($(case),)
    45  TEST_FLAGS += -test.run=$(case)
    46  UNIT_TARGETED = yes
    47  endif
    48  
    49  # Define the integration test.run filter if the icase argument was provided.
    50  ifneq ($(icase),)
    51  TEST_FLAGS += -test.run="TestLightningNetworkDaemon/tranche.*/.*-of-.*/.*/$(icase)"
    52  endif
    53  
    54  # Default to embedded wallet implementation if not set.
    55  ifneq ($(walletimpl),)
    56  DEV_TAGS += ${walletimpl}
    57  else
    58  DEV_TAGS += embeddedwallet
    59  endif
    60  
    61  # Run itests with specified db backend.
    62  ifneq ($(dbbackend),)
    63  ITEST_FLAGS += -dbbackend=$(dbbackend)
    64  endif
    65  
    66  ifeq ($(dbbackend),etcd)
    67  DEV_TAGS += kvdb_etcd
    68  endif
    69  
    70  ifeq ($(dbbackend),postgres)
    71  DEV_TAGS += kvdb_postgres
    72  endif
    73  
    74  ifneq ($(tags),)
    75  DEV_TAGS += ${tags}
    76  endif
    77  
    78  # Define the log tags that will be applied only when running unit tests. If none
    79  # are provided, we default to "nolog" which will be silent.
    80  ifneq ($(log),)
    81  LOG_TAGS := ${log}
    82  else
    83  LOG_TAGS := nolog
    84  endif
    85  
    86  # If a timeout was requested, construct initialize the proper flag for the go
    87  # test command. If not, we set 20m (up from the default 10m).
    88  ifneq ($(timeout),)
    89  TEST_FLAGS += -test.timeout=$(timeout)
    90  else
    91  TEST_FLAGS += -test.timeout=60m
    92  endif
    93  
    94  GOLIST := go list -tags="$(DEV_TAGS)" -deps $(PKG)/... | grep '$(PKG)'| grep -v '/vendor/'
    95  GOLISTCOVER := $(shell go list -tags="$(DEV_TAGS)" -deps -f '{{.ImportPath}}' ./... | grep '$(PKG)' | sed -e 's/^$(ESCPKG)/./')
    96  
    97  # UNIT_TARGTED is undefined iff a specific package and/or unit test case is
    98  # not being targeted.
    99  UNIT_TARGETED ?= no
   100  
   101  # If a specific package/test case was requested, run the unit test for the
   102  # targeted case. Otherwise, default to running all tests.
   103  ifeq ($(UNIT_TARGETED), yes)
   104  UNIT := $(GOTEST) -count=1 -tags="$(DEV_TAGS) $(LOG_TAGS) $(UTEST_TAGS)" $(TEST_FLAGS) $(UNITPKG)
   105  UNIT_DEBUG := $(GOTEST) -count=1 -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS) $(UNITPKG)
   106  UNIT_RACE := $(GOTEST) -count=1 -tags="$(DEV_TAGS) $(LOG_TAGS) $(UTEST_TAGS)" $(TEST_FLAGS) -race -gcflags=all=-d=checkptr=0 $(UNITPKG)
   107  endif
   108  
   109  ifeq ($(UNIT_TARGETED), no)
   110  UNIT := $(GOLIST) | xargs -I{} sh -c '$(GOTEST) -count=1 -tags="$(DEV_TAGS) $(LOG_TAGS) $(UTEST_TAGS)" $(TEST_FLAGS) {} || exit 255'
   111  UNIT_DEBUG := $(GOLIST) | $(XARGS) env $(GOTEST) -count=1 -v -tags="$(DEV_TAGS) $(LOG_TAGS)" $(TEST_FLAGS)
   112  UNIT_RACE := $(GOLIST) | xargs -I{} sh -c 'env $(RACE_ENV) $(GOTEST) -count=1 -tags="$(DEV_TAGS) $(LOG_TAGS) $(UTEST_TAGS)" $(TEST_FLAGS) -race -gcflags=all=-d=checkptr=0 {} || exit 255'
   113  endif
   114  
   115  
   116  # Construct the integration test command with the added build flags.
   117  ITEST_TAGS := $(DEV_TAGS) rpctest
   118  
   119  # Default to dcrd backend if not set.
   120  ifneq ($(backend),)
   121  ITEST_TAGS += ${backend}
   122  else
   123  ITEST_TAGS += dcrd
   124  endif