aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-05-14 13:23:12 +0200
committerLoïc Hoguin <[email protected]>2018-05-14 13:23:12 +0200
commitb92675833b3c5154a1477c18a373420b477c8196 (patch)
treefe719f61520647e16ff7b714815cd7b5e4703e3f
parentca7fcc22e1eae294a2a05f89b2f95c20f7e2ceb6 (diff)
downloaderlang.mk-b92675833b3c5154a1477c18a373420b477c8196.tar.gz
erlang.mk-b92675833b3c5154a1477c18a373420b477c8196.tar.bz2
erlang.mk-b92675833b3c5154a1477c18a373420b477c8196.zip
Fix use of templates from plugins in apps layout
-rw-r--r--plugins/bootstrap.mk2
-rw-r--r--test/core_plugins.mk46
2 files changed, 45 insertions, 3 deletions
diff --git a/plugins/bootstrap.mk b/plugins/bootstrap.mk
index 8ba8b08..6c26a0f 100644
--- a/plugins/bootstrap.mk
+++ b/plugins/bootstrap.mk
@@ -493,7 +493,7 @@ ifndef n
$(error Usage: $(MAKE) new t=TEMPLATE n=NAME [in=APP])
endif
ifdef in
- $(verbose) $(MAKE) -C $(APPS_DIR)/$(in)/ new t=$t n=$n in=
+ $(call render_template,tpl_$(t),$(APPS_DIR)/$(in)/src/$(n).erl)
else
$(call render_template,tpl_$(t),src/$(n).erl)
endif
diff --git a/test/core_plugins.mk b/test/core_plugins.mk
index 508012b..ed6581d 100644
--- a/test/core_plugins.mk
+++ b/test/core_plugins.mk
@@ -1,6 +1,6 @@
# Core: External plugins.
-CORE_PLUGINS_CASES = all early early-local local one templates test
+CORE_PLUGINS_CASES = all early early-local local one templates templates-apps-only test
CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES))
.PHONY: core-plugins $(CORE_PLUGINS_TARGETS)
@@ -166,7 +166,7 @@ core-plugins-templates: build clean
$t $(MAKE) --no-print-directory -C $(APP) list-templates | grep -qw test_mk
$i "Create a new file using the template"
- $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk
+ $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk $v
$i "Confirm the file exists"
$t test -f $(APP)/src/test_mk.erl
@@ -177,6 +177,48 @@ core-plugins-templates: build clean
$i "Check that the file was compiled correctly"
$t test -f $(APP)/ebin/test_mk.beam
+core-plugins-templates-apps-only: build clean
+
+ $i "Create a multi application repository with no root application"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t echo "include erlang.mk" > $(APP)/Makefile
+
+ $i "Create a new application my_app"
+ $t $(MAKE) -C $(APP) new-app in=my_app $v
+
+ $i "Create a local git repository with a plugin containing a template"
+ $t mkdir -p $(APP)/plugin_dep
+ $t printf "%s\n" \
+ "define tpl_test_mk" \
+ "-module(test_mk)." \
+ "endef" > $(APP)/plugin_dep/plugins.mk
+ $t cd $(APP)/plugin_dep && \
+ git init -q && \
+ git config user.email "[email protected]" && \
+ git config user.name "test suite" && \
+ git add . && \
+ git commit -q --no-gpg-sign -m "Tests"
+
+ $i "Add dependency and plugins to the Makefile"
+ $t printf "%s\n" \
+ "DEPS = plugin_dep" \
+ "dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master" \
+ "DEP_PLUGINS = plugin_dep" \
+ "include erlang.mk" > $(APP)/Makefile
+
+ $i "Create a new file using the template in the my_app application"
+ $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk in=my_app $v
+
+ $i "Confirm the file exists"
+ $t test -f $(APP)/apps/my_app/src/test_mk.erl
+
+ $i "Build the application"
+ $t $(MAKE) -C $(APP) $v
+
+ $i "Check that the file was compiled correctly"
+ $t test -f $(APP)/apps/my_app/ebin/test_mk.beam
+
core-plugins-test: build clean
$i "Bootstrap a new OTP library named $(APP)"