diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/ct.mk | 60 | ||||
-rw-r--r-- | plugins/elvis.mk | 10 | ||||
-rw-r--r-- | plugins/eunit.mk | 50 | ||||
-rw-r--r-- | plugins/triq.mk | 29 |
4 files changed, 65 insertions, 84 deletions
diff --git a/plugins/ct.mk b/plugins/ct.mk index 18d432a..b281842 100644 --- a/plugins/ct.mk +++ b/plugins/ct.mk @@ -1,77 +1,55 @@ # Copyright (c) 2013-2014, Loïc Hoguin <[email protected]> # This file is part of erlang.mk and subject to the terms of the ISC License. -.PHONY: build-ct-deps build-ct-suites tests-ct clean-ct distclean-ct +.PHONY: ct distclean-ct # Configuration. CT_OPTS ?= -ifneq ($(wildcard test/),) - CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find test -type f -name \*_SUITE.erl -exec basename {} \;))) +ifneq ($(wildcard $(TEST_DIR)),) + CT_SUITES ?= $(sort $(subst _SUITE.erl,,$(shell find $(TEST_DIR) -type f -name \*_SUITE.erl -exec basename {} \;))) else CT_SUITES ?= endif -TEST_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard -TEST_ERLC_OPTS += -DTEST=1 -DEXTRA=1 +'{parse_transform, eunit_autoexport}' - # Core targets. -tests:: tests-ct - -clean:: clean-ct +tests:: ct distclean:: distclean-ct help:: @printf "%s\n" "" \ + "Common_test targets:" \ + " ct Run all the common_test suites for this project" \ + "" \ "All your common_test suites have their associated targets." \ "A suite named http_SUITE can be ran using the ct-http target." # Plugin-specific targets. -ALL_TEST_DEPS_DIRS = $(addprefix $(DEPS_DIR)/,$(TEST_DEPS)) - CT_RUN = ct_run \ -no_auto_compile \ -noinput \ - -pa $(realpath ebin) $(DEPS_DIR)/*/ebin \ - -dir test \ + -pa ebin $(DEPS_DIR)/*/ebin \ + -dir $(TEST_DIR) \ -logdir logs -$(foreach dep,$(TEST_DEPS),$(eval $(call dep_target,$(dep)))) - -build-ct-deps: $(ALL_TEST_DEPS_DIRS) - @for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep; done - -build-ct-suites: build-ct-deps - $(gen_verbose) erlc -v $(TEST_ERLC_OPTS) -I include/ -o test/ \ - $(wildcard test/*.erl test/*/*.erl) -pa ebin/ - -tests-ct: ERLC_OPTS = $(TEST_ERLC_OPTS) -tests-ct: clean deps app build-ct-suites - @if [ -d "test" ] ; \ - then \ - mkdir -p logs/ ; \ - $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS) ; \ - fi - $(gen_verbose) rm -f test/*.beam +ifeq ($(CT_SUITES),) +ct: +else +ct: test-build + @mkdir -p logs/ + $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS) +endif define ct_suite_target -ct-$(1): ERLC_OPTS = $(TEST_ERLC_OPTS) -ct-$(1): clean deps app build-ct-suites - @if [ -d "test" ] ; \ - then \ - mkdir -p logs/ ; \ - $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS) ; \ - fi - $(gen_verbose) rm -f test/*.beam +ct-$(1): test-build + @mkdir -p logs/ + $(gen_verbose) $(CT_RUN) -suite $(addsuffix _SUITE,$(1)) $(CT_OPTS) endef $(foreach test,$(CT_SUITES),$(eval $(call ct_suite_target,$(test)))) -clean-ct: - $(gen_verbose) rm -rf test/*.beam - distclean-ct: $(gen_verbose) rm -rf logs/ diff --git a/plugins/elvis.mk b/plugins/elvis.mk index f3e75a8..580e2f5 100644 --- a/plugins/elvis.mk +++ b/plugins/elvis.mk @@ -21,20 +21,18 @@ help:: "Elvis targets:" \ " elvis Run Elvis using the local elvis.config or download the default otherwise" -ifneq ($(wildcard $(ELVIS_CONFIG)),) -rel:: distclean-elvis -endif - distclean:: distclean-elvis # Plugin-specific targets. $(ELVIS): - @$(call core_http_get,$(ELVIS_CONFIG),$(ELVIS_CONFIG_URL)) @$(call core_http_get,$(ELVIS),$(ELVIS_URL)) @chmod +x $(ELVIS) -elvis: $(ELVIS) +$(ELVIS_CONFIG): + @$(call core_http_get,$(ELVIS_CONFIG),$(ELVIS_CONFIG_URL)) + +elvis: $(ELVIS) $(ELVIS_CONFIG) @$(ELVIS) rock -c $(ELVIS_CONFIG) $(ELVIS_OPTS) distclean-elvis: diff --git a/plugins/eunit.mk b/plugins/eunit.mk index 1b83a0f..ae132ac 100644 --- a/plugins/eunit.mk +++ b/plugins/eunit.mk @@ -1,25 +1,20 @@ # Copyright (c) 2014, Enrique Fernandez <[email protected]> # This file is contributed to erlang.mk and subject to the terms of the ISC License. -.PHONY: help-eunit build-eunit eunit distclean-eunit +.PHONY: eunit # Configuration -EUNIT_ERLC_OPTS ?= +debug_info +warn_export_vars +warn_shadow_vars +warn_obsolete_guard -DTEST=1 -DEXTRA=1 - -EUNIT_DIR ?= -EUNIT_DIRS = $(sort $(EUNIT_DIR) ebin) - -ifeq ($(strip $(EUNIT_DIR)),) +ifeq ($(strip $(TEST_DIR)),) TAGGED_EUNIT_TESTS = {dir,"ebin"} else -# All modules in EUNIT_DIR -EUNIT_DIR_MODS = $(notdir $(basename $(shell find $(EUNIT_DIR) -type f -name *.beam))) +# All modules in TEST_DIR +TEST_DIR_MODS = $(notdir $(basename $(shell find $(TEST_DIR) -type f -name *.beam))) # All modules in 'ebin' EUNIT_EBIN_MODS = $(notdir $(basename $(shell find ebin -type f -name *.beam))) -# Only those modules in EUNIT_DIR with no matching module in 'ebin'. +# 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)),$(EUNIT_DIR_MODS)) +EUNIT_MODS = $(filter-out $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(TEST_DIR_MODS)) TAGGED_EUNIT_TESTS = {dir,"ebin"} $(foreach mod,$(EUNIT_MODS),$(shell echo $(mod) | sed -e 's/\(.*\)/{module,\1}/g')) endif @@ -33,38 +28,19 @@ endef # Core targets. -help:: help-eunit - tests:: eunit -clean:: clean-eunit +help:: + @printf "%s\n" "" \ + "EUnit targets:" \ + " eunit Run all the EUnit tests for this project" # Plugin-specific targets. EUNIT_RUN = $(ERL) \ - -no_auto_compile \ - -pa $(realpath $(EUNIT_DIR)) $(DEPS_DIR)/*/ebin \ - -pz $(realpath ebin) \ + -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin \ + -pz ebin \ -eval 'case eunit:test([$(call str-join,$(TAGGED_EUNIT_TESTS))], [$(EUNIT_OPTS)]) of ok -> halt(0); error -> halt(1) end.' -help-eunit: - @printf "%s\n" "" \ - "EUnit targets:" \ - " eunit Run all the EUnit tests for this project" - -ifeq ($(strip $(EUNIT_DIR)),) -build-eunit: -else ifeq ($(strip $(EUNIT_DIR)),ebin) -build-eunit: -else -build-eunit: - $(gen_verbose) erlc -v $(EUNIT_ERLC_OPTS) -I include/ -o $(EUNIT_DIR) \ - $(wildcard $(EUNIT_DIR)/*.erl $(EUNIT_DIR)/*/*.erl) -pa ebin/ -endif - -eunit: ERLC_OPTS = $(EUNIT_ERLC_OPTS) -eunit: clean deps app build-eunit +eunit: test-build $(gen_verbose) $(EUNIT_RUN) - -clean-eunit: - $(gen_verbose) $(foreach dir,$(EUNIT_DIRS),rm -rf $(dir)/*.beam) diff --git a/plugins/triq.mk b/plugins/triq.mk new file mode 100644 index 0000000..8a77c91 --- /dev/null +++ b/plugins/triq.mk @@ -0,0 +1,29 @@ +# Copyright (c) 2015, Loïc Hoguin <[email protected]> +# This file is part of erlang.mk and subject to the terms of the ISC License. + +.PHONY: triq + +# Targets. + +tests:: triq + +define triq_run +$(ERL) -pa $(CURDIR)/ebin $(DEPS_DIR)/*/ebin \ + -eval "try $(1) of true -> halt(0); _ -> halt(1) catch error:undef -> io:format(\"Undefined property or module~n\"), halt() end." +endef + +ifdef t +ifeq (,$(findstring :,$(t))) +triq: test-build + @$(call triq_run,triq:check($(t))) +else +triq: test-build + @echo Testing $(t)/0 + @$(call triq_run,triq:check($(t)())) +endif +else +triq: test-build + $(eval MODULES := $(shell find ebin -type f -name \*.beam \ + | sed "s/ebin\//'/;s/\.beam/',/" | sed '$$s/.$$//')) + $(gen_verbose) $(call triq_run,[true] =:= lists:usort([triq:check(M) || M <- [$(MODULES)]])) +endif |