From 5f064a8e42cbb23e5d1ec471aa468e33ab8e5846 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Thu, 11 Mar 2021 17:28:52 +0100 Subject: [PATCH] chore(test): enable cover only when necessary So that ad-hoc ./rebar3 eunit and ct can run faster --- Makefile | 10 +++++----- rebar.config | 1 - rebar.config.erl | 10 +++++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 69682f29c..97072f81a 100644 --- a/Makefile +++ b/Makefile @@ -33,23 +33,23 @@ get-dashboard: .PHONY: eunit eunit: $(REBAR) - @$(REBAR) eunit -v -c + @ENABLE_COVER_COMPILE=1 $(REBAR) eunit -v -c .PHONY: proper proper: $(REBAR) - @$(REBAR) as test proper -d test/props -c + @ENABLE_COVER_COMPILE=1 $(REBAR) as test proper -d test/props -c .PHONY: ct ct: $(REBAR) - @$(REBAR) ct --name 'test@127.0.0.1' -c -v + @ENABLE_COVER_COMPILE=1 $(REBAR) ct --name 'test@127.0.0.1' -c -v .PHONY: cover cover: $(REBAR) - @$(REBAR) cover + @ENABLE_COVER_COMPILE=1 $(REBAR) cover .PHONY: coveralls coveralls: $(REBAR) - @$(REBAR) as test coveralls send + @ENABLE_COVER_COMPILE=1 $(REBAR) as test coveralls send .PHONY: $(REL_PROFILES) $(REL_PROFILES:%=%): $(REBAR) get-dashboard diff --git a/rebar.config b/rebar.config index f1fe1d3b2..4b99dde2d 100644 --- a/rebar.config +++ b/rebar.config @@ -24,7 +24,6 @@ ] }. -{cover_enabled, true}. {cover_opts, [verbose]}. {cover_export_enabled, true}. {cover_excl_mods, [emqx_exproto_pb, emqx_exhook_pb]}. diff --git a/rebar.config.erl b/rebar.config.erl index 7fb892124..47ba3a3d9 100644 --- a/rebar.config.erl +++ b/rebar.config.erl @@ -50,11 +50,19 @@ community_plugin_overrides() -> [{add, App, [ {erl_opts, [{i, "include"}]}]} || App <- relx_plugin_apps_extra()]. config() -> - [ {plugins, plugins()} + [ {cover_enabled, is_cover_enabled()} + , {plugins, plugins()} , {profiles, profiles()} , {project_app_dirs, project_app_dirs()} ]. +is_cover_enabled() -> + case os:getenv("ENABLE_COVER_COMPILE") of + "1"-> true; + "true" -> true; + _ -> false + end. + is_enterprise() -> filelib:is_regular("EMQX_ENTERPRISE").