aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/deps.mk2
-rw-r--r--core/test.mk37
-rw-r--r--plugins/ct.mk8
-rw-r--r--plugins/eunit.mk2
-rw-r--r--test/plugin_ct.mk42
5 files changed, 52 insertions, 39 deletions
diff --git a/core/deps.mk b/core/deps.mk
index 19a2410..d5b12a6 100644
--- a/core/deps.mk
+++ b/core/deps.mk
@@ -98,7 +98,7 @@ endif
:; \
else \
echo $$dep >> $(ERLANG_MK_TMP)/apps.log; \
- $(MAKE) -C $$dep IS_APP=1; \
+ $(MAKE) -C $$dep $(if $(IS_TEST),test-build-app) IS_APP=1; \
fi \
done
diff --git a/core/test.mk b/core/test.mk
index 3cdcfb7..a9481fd 100644
--- a/core/test.mk
+++ b/core/test.mk
@@ -29,20 +29,34 @@ test-dir:
-pa ebin/ -I include/ $(call core_find,$(TEST_DIR)/,*.erl)
endif
-ifeq ($(wildcard src),)
+test-build:: IS_TEST=1
test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
-test-build:: clean deps test-deps
+test-build:: $(if $(wildcard src),$(if $(wildcard ebin/test),,clean)) $(if $(IS_APP),,deps test-deps)
+# We already compiled everything when IS_APP=1.
+ifndef IS_APP
+ifneq ($(wildcard $(TEST_DIR)),)
$(verbose) $(MAKE) --no-print-directory test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
-else
-ifeq ($(wildcard ebin/test),)
-test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
-test-build:: clean deps test-deps $(PROJECT).d
- $(verbose) $(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
+endif
+ifneq ($(wildcard src),)
+ $(verbose) $(MAKE) --no-print-directory $(PROJECT).d ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
+ $(verbose) $(MAKE) --no-print-directory app-build ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
$(gen_verbose) touch ebin/test
-else
-test-build:: ERLC_OPTS=$(TEST_ERLC_OPTS)
-test-build:: deps test-deps $(PROJECT).d
- $(verbose) $(MAKE) --no-print-directory app-build test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
+endif
+endif
+
+# Roughly the same as test-build, but when IS_APP=1.
+# We only care about compiling the current application.
+ifdef IS_APP
+test-build-app:: ERLC_OPTS=$(TEST_ERLC_OPTS)
+test-build-app:: test-deps
+ifneq ($(wildcard $(TEST_DIR)),)
+ $(verbose) $(MAKE) --no-print-directory test-dir ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
+endif
+ifneq ($(wildcard src),)
+ $(verbose) $(MAKE) --no-print-directory $(PROJECT).d ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
+ $(verbose) $(MAKE) --no-print-directory app-build ERLC_OPTS="$(call escape_dquotes,$(TEST_ERLC_OPTS))"
+ $(gen_verbose) touch ebin/test
+endif
endif
clean:: clean-test-dir
@@ -51,4 +65,3 @@ clean-test-dir:
ifneq ($(wildcard $(TEST_DIR)/*.beam),)
$(gen_verbose) rm -f $(TEST_DIR)/*.beam
endif
-endif
diff --git a/plugins/ct.mk b/plugins/ct.mk
index 63f61fa..b9199e9 100644
--- a/plugins/ct.mk
+++ b/plugins/ct.mk
@@ -41,11 +41,11 @@ CT_RUN = ct_run \
-logdir $(CT_LOGS_DIR)
ifeq ($(CT_SUITES),)
-ct: $(if $(IS_APP),,apps-ct)
+ct: $(if $(IS_APP)$(ROOT_DIR),,apps-ct)
else
# We do not run tests if we are in an apps/* with no test directory.
ifneq ($(IS_APP)$(wildcard $(TEST_DIR)),1)
-ct: test-build $(if $(IS_APP),,apps-ct)
+ct: test-build $(if $(IS_APP)$(ROOT_DIR),,apps-ct)
$(verbose) mkdir -p $(CT_LOGS_DIR)
$(gen_verbose) $(CT_RUN) -sname ct_$(PROJECT) -suite $(addsuffix _SUITE,$(CT_SUITES)) $(CT_OPTS)
endif
@@ -53,13 +53,13 @@ endif
ifneq ($(ALL_APPS_DIRS),)
define ct_app_target
-apps-ct-$1:
+apps-ct-$1: test-build
$(MAKE) -C $1 ct IS_APP=1
endef
$(foreach app,$(ALL_APPS_DIRS),$(eval $(call ct_app_target,$(app))))
-apps-ct: test-build $(addprefix apps-ct-,$(ALL_APPS_DIRS))
+apps-ct: $(addprefix apps-ct-,$(ALL_APPS_DIRS))
endif
ifndef t
diff --git a/plugins/eunit.mk b/plugins/eunit.mk
index c94c63d..8c08334 100644
--- a/plugins/eunit.mk
+++ b/plugins/eunit.mk
@@ -69,7 +69,7 @@ ifneq ($(wildcard src/ $(TEST_DIR)),)
endif
ifneq ($(ALL_APPS_DIRS),)
-apps-eunit:
+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
diff --git a/test/plugin_ct.mk b/test/plugin_ct.mk
index 4c5945a..82d42e3 100644
--- a/test/plugin_ct.mk
+++ b/test/plugin_ct.mk
@@ -87,46 +87,46 @@ ct-apps-only: build clean
$t cp ../erlang.mk $(APP)/
$t echo "include erlang.mk" > $(APP)/Makefile
- $i "Create a new application named my_app"
- $t $(MAKE) -C $(APP) new-app in=my_app $v
+ $i "Create a new application named my_app_only"
+ $t $(MAKE) -C $(APP) new-app in=my_app_only $v
- $i "Create a new library named my_lib"
- $t $(MAKE) -C $(APP) new-lib in=my_lib $v
+ $i "Create a new library named my_lib_only"
+ $t $(MAKE) -C $(APP) new-lib in=my_lib_only $v
- $i "Populate my_lib"
+ $i "Populate my_lib_only"
$t printf "%s\n" \
- "-module(my_lib)." \
+ "-module(my_lib_only)." \
"-export([random_int/0])." \
- "random_int() -> 4." > $(APP)/apps/my_lib/src/my_lib.erl
+ "random_int() -> 4." > $(APP)/apps/my_lib_only/src/my_lib_only.erl
$i "Check that Common Test detects no tests"
$t $(MAKE) -C $(APP) ct | grep -c "Nothing to be done for 'ct'." | grep -q 2
- $i "Generate a Common Test suite in my_app"
- $t mkdir $(APP)/apps/my_app/test
+ $i "Generate a Common Test suite in my_app_only"
+ $t mkdir $(APP)/apps/my_app_only/test
$t printf "%s\n" \
- "-module(my_app_SUITE)." \
- "-export([all/0, ok/1, call_my_lib/1])." \
- "all() -> [ok, call_my_lib]." \
+ "-module(my_app_only_SUITE)." \
+ "-export([all/0, ok/1, call_my_lib_only/1])." \
+ "all() -> [ok, call_my_lib_only]." \
"ok(_) -> ok." \
- "call_my_lib(_) -> 4 = my_lib:random_int()." > $(APP)/apps/my_app/test/my_app_SUITE.erl
+ "call_my_lib_only(_) -> 4 = my_lib_only:random_int()." > $(APP)/apps/my_app_only/test/my_app_only_SUITE.erl
- $i "Generate a Common Test suite in my_lib"
- $t mkdir $(APP)/apps/my_lib/test
+ $i "Generate a Common Test suite in my_lib_only"
+ $t mkdir $(APP)/apps/my_lib_only/test
$t printf "%s\n" \
- "-module(my_lib_SUITE)." \
+ "-module(my_lib_only_SUITE)." \
"-export([all/0, ok/1])." \
"all() -> [ok]." \
- "ok(_) -> ok." > $(APP)/apps/my_lib/test/my_lib_SUITE.erl
+ "ok(_) -> ok." > $(APP)/apps/my_lib_only/test/my_lib_only_SUITE.erl
$i "Check that Common Test runs tests"
# We can't pipe CT's output without it crashing, so let's check that
# the command succeeds and log files are created instead.
- $t test ! -e $(APP)/apps/my_app/logs/index.html
- $t test ! -e $(APP)/apps/my_lib/logs/index.html
+ $t test ! -e $(APP)/apps/my_app_only/logs/index.html
+ $t test ! -e $(APP)/apps/my_lib_only/logs/index.html
$t $(MAKE) -C $(APP) ct $v
- $t test -f $(APP)/apps/my_app/logs/index.html
- $t test -f $(APP)/apps/my_lib/logs/index.html
+ $t test -f $(APP)/apps/my_app_only/logs/index.html
+ $t test -f $(APP)/apps/my_lib_only/logs/index.html
ct-case: build clean