From 9b3676fdd4caba88c62035fa296ecafc97c71d9d Mon Sep 17 00:00:00 2001 From: AdamISZ Date: Tue, 21 May 2019 12:33:07 +0200 Subject: [PATCH] Allow unit-cover target for make to filter by package Previous to this commit, running `make unit-cover pkg=xx` would ignore the selected package and run unit tests and coverage for all packages. After this commit, the package selected with pkg= is the only one that is tested and coverage output generated for. If no pkg is selected, the default is as before, all pkgs. --- Makefile | 3 ++- make/testing_flags.mk | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 79b7e04f..a21ab026 100644 --- a/Makefile +++ b/Makefile @@ -126,7 +126,8 @@ unit: btcd unit-cover: $(GOACC_BIN) @$(call print, "Running unit coverage tests.") - $(GOACC_BIN) $$(go list ./... | grep -v lnrpc) -- -test.tags="$(DEV_TAGS) $(LOG_TAGS)" + $(GOACC_BIN) $(COVER_PKG) -- -test.tags="$(DEV_TAGS) $(LOG_TAGS)" + unit-race: @$(call print, "Running unit race tests.") diff --git a/make/testing_flags.mk b/make/testing_flags.mk index eb5b43b1..177dcd98 100644 --- a/make/testing_flags.mk +++ b/make/testing_flags.mk @@ -1,12 +1,14 @@ DEV_TAGS = dev LOG_TAGS = TEST_FLAGS = +COVER_PKG = $$(go list ./... | grep -v lnrpc) # If specific package is being unit tested, construct the full name of the # subpackage. ifneq ($(pkg),) UNITPKG := $(PKG)/$(pkg) UNIT_TARGETED = yes +COVER_PKG = $(PKG)/$(pkg) endif # If a specific unit test case is being target, construct test.run filter.