diff options
author | Loïc Hoguin <[email protected]> | 2015-01-10 18:25:22 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2015-01-10 18:41:44 +0100 |
commit | 7ee4e7958acf0f0956bd64023ecb1731b2824b5e (patch) | |
tree | bdeee9ec023b237d02cff28d9a33e6589877cb4f /plugins/ct.mk | |
parent | 098aa65854199fe1f58e4bd870f948bdd597741a (diff) | |
download | erlang.mk-7ee4e7958acf0f0956bd64023ecb1731b2824b5e.tar.gz erlang.mk-7ee4e7958acf0f0956bd64023ecb1731b2824b5e.tar.bz2 erlang.mk-7ee4e7958acf0f0956bd64023ecb1731b2824b5e.zip |
Introduce test builds and unify testing tools interface
The general idea is that erlang.mk now keeps track of what kind
of build it generated. A test build is valid for all subsequent
test target invocations. A normal build is only valid for itself
and releases.
This rework adds the ability to specify deps to eunit.
The EUNIT_DIR variable is gone in favor of a more global TEST_DIR.
The tests-ct target got renamed to ct and documented.
Many more minor changes were done during the course of testing
these changes.
Diffstat (limited to 'plugins/ct.mk')
-rw-r--r-- | plugins/ct.mk | 60 |
1 files changed, 19 insertions, 41 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/ |