diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/c_src.mk | 2 | ||||
-rw-r--r-- | plugins/ct.mk | 2 | ||||
-rw-r--r-- | plugins/erlydtl.mk | 2 | ||||
-rw-r--r-- | plugins/eunit.mk | 58 | ||||
-rw-r--r-- | plugins/protobuffs.mk | 2 | ||||
-rw-r--r-- | plugins/triq.mk | 7 |
6 files changed, 34 insertions, 39 deletions
diff --git a/plugins/c_src.mk b/plugins/c_src.mk index 34e4952..98417ed 100644 --- a/plugins/c_src.mk +++ b/plugins/c_src.mk @@ -64,7 +64,7 @@ clean:: else ifeq ($(SOURCES),) -SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \)) +SOURCES := $(sort $(call core_find,$(C_SRC_DIR)/,*.c *.C *.cc *.cpp)) endif OBJECTS = $(addsuffix .o, $(basename $(SOURCES))) diff --git a/plugins/ct.mk b/plugins/ct.mk index eba0e52..7e0f683 100644 --- a/plugins/ct.mk +++ b/plugins/ct.mk @@ -7,7 +7,7 @@ CT_OPTS ?= ifneq ($(wildcard $(TEST_DIR)),) - CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find $(TEST_DIR) -type f -name \*_SUITE.erl -exec basename {} \;))) + CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(notdir $(call core_find,$(TEST_DIR)/,*_SUITE.erl)))) else CT_SUITES ?= endif diff --git a/plugins/erlydtl.mk b/plugins/erlydtl.mk index d65231d..46a3080 100644 --- a/plugins/erlydtl.mk +++ b/plugins/erlydtl.mk @@ -26,6 +26,6 @@ define compile_erlydtl endef ifneq ($(wildcard src/),) -ebin/$(PROJECT).app:: $(shell find templates -type f -name \*.dtl 2>/dev/null) +ebin/$(PROJECT).app:: $(sort $(call core_find,templates/,*.dtl)) $(if $(strip $?),$(call compile_erlydtl,$?)) endif diff --git a/plugins/eunit.mk b/plugins/eunit.mk index b9f2856..79add79 100644 --- a/plugins/eunit.mk +++ b/plugins/eunit.mk @@ -6,28 +6,8 @@ # Configuration -# All modules in TEST_DIR -ifeq ($(strip $(TEST_DIR)),) -TEST_DIR_MODS = -else -TEST_DIR_MODS = $(notdir $(basename $(shell find $(TEST_DIR) -type f -name *.beam))) -endif - -# All modules in 'ebin' -EUNIT_EBIN_MODS = $(notdir $(basename $(shell find ebin -type f -name *.beam))) -# Only those modules in TEST_DIR with no matching module in 'ebin'. -# This is done to avoid some tests being executed twice. -EUNIT_MODS = $(filter-out $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(TEST_DIR_MODS)) -TAGGED_EUNIT_TESTS = $(foreach mod,$(EUNIT_EBIN_MODS) $(EUNIT_MODS),{module,$(mod)}) - EUNIT_OPTS ?= -# Utility functions - -define str-join - $(shell echo '$(strip $(1))' | sed -e "s/ /,/g") -endef - # Core targets. tests:: eunit @@ -39,16 +19,32 @@ help:: # Plugin-specific targets. -EUNIT_RUN_BEFORE ?= -EUNIT_RUN_AFTER ?= -EUNIT_RUN = $(ERL) \ - -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin \ - -pz ebin \ - $(EUNIT_RUN_BEFORE) \ - -eval 'case eunit:test([$(call str-join,$(TAGGED_EUNIT_TESTS))],\ - [$(EUNIT_OPTS)]) of ok -> ok; error -> halt(1) end.' \ - $(EUNIT_RUN_AFTER) \ - -eval 'halt(0).' +define eunit.erl + case "$(COVER)" of + "" -> ok; + _ -> + case cover:compile_beam_directory("ebin") of + {error, _} -> halt(1); + _ -> ok + end + end, + case eunit:test([$(call comma_list,$(1))], [$(EUNIT_OPTS)]) of + ok -> ok; + error -> halt(2) + end, + case "$(COVER)" of + "" -> ok; + _ -> + cover:export("eunit.coverdata") + end, + halt() +endef + +EUNIT_EBIN_MODS = $(notdir $(basename $(call core_find,ebin/,*.beam))) +EUNIT_TEST_MODS = $(notdir $(basename $(call core_find,$(TEST_DIR)/,*.beam))) +EUNIT_MODS = $(foreach mod,$(EUNIT_EBIN_MODS) $(filter-out \ + $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(EUNIT_TEST_MODS)),{module,'$(mod)'}) eunit: test-build - $(gen_verbose) $(EUNIT_RUN) + $(gen_verbose) $(ERL) -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin ebin \ + -eval "$(subst $(newline),,$(subst ",\",$(call eunit.erl,$(EUNIT_MODS))))" diff --git a/plugins/protobuffs.mk b/plugins/protobuffs.mk index d180b1f..b0400bf 100644 --- a/plugins/protobuffs.mk +++ b/plugins/protobuffs.mk @@ -26,6 +26,6 @@ define compile_proto.erl endef ifneq ($(wildcard src/),) -ebin/$(PROJECT).app:: $(shell find src -type f -name \*.proto 2>/dev/null) +ebin/$(PROJECT).app:: $(sort $(call core_find,src/,*.proto)) $(if $(strip $?),$(call compile_proto,$?)) endif diff --git a/plugins/triq.mk b/plugins/triq.mk index f487f8c..702491d 100644 --- a/plugins/triq.mk +++ b/plugins/triq.mk @@ -12,7 +12,7 @@ define triq_check.erl code:add_pathsa(["$(CURDIR)/ebin", "$(DEPS_DIR)/*/ebin"]), try case $(1) of - all -> [true] =:= lists:usort([triq:check(M) || M <- [$(MODULES)]]); + all -> [true] =:= lists:usort([triq:check(M) || M <- [$(call comma_list,$(3))]]); module -> triq:check($(2)); function -> triq:check($(2)) end @@ -36,8 +36,7 @@ triq: test-build endif else triq: test-build - $(eval MODULES := $(shell find ebin -type f -name \*.beam \ - | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//')) - $(gen_verbose) $(call erlang,$(call triq_check.erl,all,undefined)) + $(eval MODULES := $(patsubst %,'%',$(sort $(notdir $(basename $(wildcard ebin/*.beam)))))) + $(gen_verbose) $(call erlang,$(call triq_check.erl,all,undefined,$(MODULES))) endif endif |