123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- # Copyright (c) 2015-2016, Loïc Hoguin <essen@ninenines.eu>
- # Copyright (c) 2014, Enrique Fernandez <enrique.fernandez@erlang-solutions.com>
- # This file is contributed to erlang.mk and subject to the terms of the ISC License.
- .PHONY: eunit apps-eunit
- # Configuration
- EUNIT_OPTS ?=
- EUNIT_ERL_OPTS ?=
- EUNIT_TEST_SPEC ?= $1
- # Core targets.
- tests:: eunit
- help::
- $(verbose) printf "%s\n" "" \
- "EUnit targets:" \
- " eunit Run all the EUnit tests for this project"
- # Plugin-specific targets.
- define eunit.erl
- $(call cover.erl)
- CoverSetup(),
- case eunit:test($(call EUNIT_TEST_SPEC,$1), [$(EUNIT_OPTS)]) of
- ok -> ok;
- error -> halt(2)
- end,
- CoverExport("$(call core_native_path,$(COVER_DATA_DIR))/eunit.coverdata"),
- halt()
- endef
- EUNIT_ERL_OPTS += -pa $(TEST_DIR) $(CURDIR)/ebin
- ifdef t
- ifeq (,$(findstring :,$(t)))
- eunit: test-build cover-data-dir
- $(gen_verbose) $(call erlang,$(call eunit.erl,['$(t)']),$(EUNIT_ERL_OPTS))
- else
- eunit: test-build cover-data-dir
- $(gen_verbose) $(call erlang,$(call eunit.erl,fun $(t)/0),$(EUNIT_ERL_OPTS))
- endif
- else
- EUNIT_EBIN_MODS = $(notdir $(basename $(ERL_FILES) $(BEAM_FILES)))
- EUNIT_TEST_MODS = $(notdir $(basename $(call core_find,$(TEST_DIR)/,*.erl)))
- EUNIT_MODS = $(foreach mod,$(EUNIT_EBIN_MODS) $(filter-out \
- $(patsubst %,%_tests,$(EUNIT_EBIN_MODS)),$(EUNIT_TEST_MODS)),'$(mod)')
- eunit: test-build $(if $(IS_APP)$(ROOT_DIR),,apps-eunit) cover-data-dir
- ifneq ($(wildcard src/ $(TEST_DIR)),)
- $(gen_verbose) $(call erlang,$(call eunit.erl,[$(call comma_list,$(EUNIT_MODS))]),$(EUNIT_ERL_OPTS))
- endif
- ifneq ($(ALL_APPS_DIRS),)
- apps-eunit: test-build
- $(verbose) eunit_retcode=0 ; for app in $(ALL_APPS_DIRS); do $(MAKE) -C $$app eunit IS_APP=1; \
- [ $$? -ne 0 ] && eunit_retcode=1 ; done ; \
- exit $$eunit_retcode
- endif
- endif
|