aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/eunit.mk
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-12-24 14:15:35 +0100
committerLoïc Hoguin <[email protected]>2015-12-24 14:15:35 +0100
commit769427de5f28751134ef9684398b1ad780113515 (patch)
tree13f3b296feeaa835ae43937ed454f594ea3b3bfd /plugins/eunit.mk
parent671bf97ca91f82bfccf199a1a25f17527f708a39 (diff)
downloaderlang.mk-769427de5f28751134ef9684398b1ad780113515.tar.gz
erlang.mk-769427de5f28751134ef9684398b1ad780113515.tar.bz2
erlang.mk-769427de5f28751134ef9684398b1ad780113515.zip
Add EUnit tests and documentation
Also includes a fix for multi-application repositories.
Diffstat (limited to 'plugins/eunit.mk')
-rw-r--r--plugins/eunit.mk28
1 files changed, 22 insertions, 6 deletions
diff --git a/plugins/eunit.mk b/plugins/eunit.mk
index 2adf4a6..36de6e7 100644
--- a/plugins/eunit.mk
+++ b/plugins/eunit.mk
@@ -2,7 +2,7 @@
# Copyright (c) 2015, Loïc Hoguin <[email protected]>
# This file is contributed to erlang.mk and subject to the terms of the ISC License.
-.PHONY: eunit
+.PHONY: eunit apps-eunit
# Configuration
@@ -28,7 +28,7 @@ define eunit.erl
_ -> ok
end
end,
- case eunit:test([$(call comma_list,$(1))], [$(EUNIT_OPTS)]) of
+ case eunit:test($1, [$(EUNIT_OPTS)]) of
ok -> ok;
error -> halt(2)
end,
@@ -40,11 +40,27 @@ define eunit.erl
halt()
endef
+EUNIT_PATHS = -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin $(APPS_DIR)/*/ebin ebin
+
+ifdef t
+ifeq (,$(findstring :,$(t)))
+eunit: test-build
+ $(gen_verbose) $(call erlang,$(call eunit.erl,['$(t)']),$(EUNIT_PATHS))
+else
+eunit: test-build
+ $(gen_verbose) $(call erlang,$(call eunit.erl,fun $(t)/0),$(EUNIT_PATHS))
+endif
+else
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)'})
+ $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(EUNIT_TEST_MODS)),'$(mod)')
-eunit: test-build
- $(gen_verbose) $(ERL) -pa $(TEST_DIR) $(DEPS_DIR)/*/ebin ebin \
- -eval "$(subst $(newline),,$(subst ",\",$(call eunit.erl,$(EUNIT_MODS))))"
+eunit: test-build $(if $(IS_APP),,apps-eunit)
+ $(gen_verbose) $(call erlang,$(call eunit.erl,[$(call comma_list,$(EUNIT_MODS))]),$(EUNIT_PATHS))
+
+ifneq ($(ALL_APPS_DIRS),)
+apps-eunit:
+ $(verbose) for app in $(ALL_APPS_DIRS); do $(MAKE) -C $$app eunit IS_APP=1; done
+endif
+endif