From 57798d7dc357528424a36f95c090e86450556885 Mon Sep 17 00:00:00 2001 From: Joseph Dunne Date: Sun, 25 Oct 2020 18:34:26 +0000 Subject: Add COVER_EXCL_MODS variable --- plugins/cover.mk | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'plugins/cover.mk') diff --git a/plugins/cover.mk b/plugins/cover.mk index 68f5b98..395e8b8 100644 --- a/plugins/cover.mk +++ b/plugins/cover.mk @@ -8,6 +8,7 @@ COVER_DATA_DIR ?= $(COVER_REPORT_DIR) ifdef COVER COVER_APPS ?= $(notdir $(ALL_APPS_DIRS)) COVER_DEPS ?= +COVER_EXCLUDE_MODS ?= endif # Code coverage for Common Test. @@ -23,7 +24,8 @@ $(TEST_DIR)/ct.cover.spec: cover-data-dir "{incl_dirs, '$(PROJECT)', [\"$(call core_native_path,$(CURDIR)/ebin)\" \ $(foreach a,$(COVER_APPS),$(comma) \"$(call core_native_path,$(APPS_DIR)/$a/ebin)\") \ $(foreach d,$(COVER_DEPS),$(comma) \"$(call core_native_path,$(DEPS_DIR)/$d/ebin)\")]}." \ - '{export,"$(call core_native_path,$(abspath $(COVER_DATA_DIR))/ct.coverdata)"}.' > $@ + '{export,"$(call core_native_path,$(abspath $(COVER_DATA_DIR))/ct.coverdata)"}.' \ + "{excl_mods, '$(PROJECT)', [$(call comma_list,$(COVER_EXCLUDE_MODS))]}." > $@ CT_RUN += -cover $(TEST_DIR)/ct.cover.spec endif @@ -38,14 +40,18 @@ define cover.erl Dirs = ["$(call core_native_path,$(CURDIR)/ebin)" $(foreach a,$(COVER_APPS),$(comma) "$(call core_native_path,$(APPS_DIR)/$a/ebin)") $(foreach d,$(COVER_DEPS),$(comma) "$(call core_native_path,$(DEPS_DIR)/$d/ebin)")], - [begin - case filelib:is_dir(Dir) of - false -> false; - true -> - case cover:compile_beam_directory(Dir) of - {error, _} -> halt(1); - _ -> true - end + Excludes = [$(call comma_list,$(foreach e,$(COVER_EXCLUDE_MODS),"$e"))], + [case file:list_dir(Dir) of + {error, enotdir} -> false; + {error, _} -> halt(2); + {ok, Files} -> + BeamFiles = [filename:join(Dir, File) || + File <- Files, + not lists:member(filename:basename(File, ".beam"), Excludes), + filename:extension(File) =:= ".beam"], + case cover:compile_beam(BeamFiles) of + {error, _} -> halt(1); + _ -> true end end || Dir <- Dirs] end, -- cgit v1.2.3