aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-04-27 00:10:36 +0200
committerLoïc Hoguin <[email protected]>2017-04-27 00:10:36 +0200
commit159da31510207da47f2472ca25c31015d1c09fd3 (patch)
tree9f88624ea302ea0c37fe979974c9db46f4b01ce3 /test
parent99606e41ca01f67b5f7809bb93d908e458efa398 (diff)
downloaderlang.mk-159da31510207da47f2472ca25c31015d1c09fd3.tar.gz
erlang.mk-159da31510207da47f2472ca25c31015d1c09fd3.tar.bz2
erlang.mk-159da31510207da47f2472ca25c31015d1c09fd3.zip
Add a test for plugin templates and fix an issue with them
Diffstat (limited to 'test')
-rw-r--r--test/core_plugins.mk40
1 files changed, 39 insertions, 1 deletions
diff --git a/test/core_plugins.mk b/test/core_plugins.mk
index 2a534e9..7cada8e 100644
--- a/test/core_plugins.mk
+++ b/test/core_plugins.mk
@@ -1,6 +1,6 @@
# Core: External plugins.
-CORE_PLUGINS_CASES = all one test
+CORE_PLUGINS_CASES = all one templates test
CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES))
.PHONY: core-plugins $(CORE_PLUGINS_TARGETS)
@@ -71,6 +71,44 @@ core-plugins-one: build clean
$i "Run 'make plugin2' and confirm the target doesn't exist"
$t ! $(MAKE) --no-print-directory -C $(APP) plugin2
+core-plugins-templates: build clean
+
+ $i "Bootstrap a new OTP library named $(APP)"
+ $t mkdir $(APP)/
+ $t cp ../erlang.mk $(APP)/
+ $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $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 -m "Tests"
+
+ $i "Add dependency and plugins to the Makefile"
+ $t perl -ni.bak -e 'print;if ($$.==1) {print "DEPS = plugin_dep\ndep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\nDEP_PLUGINS = plugin_dep\n"}' $(APP)/Makefile
+
+ $i "Run 'make list-templates' and check that it prints test_mk"
+ $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
+
+ $i "Confirm the file exists"
+ $t test -f $(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)/ebin/test_mk.beam
+
core-plugins-test: build clean
$i "Bootstrap a new OTP library named $(APP)"