aboutsummaryrefslogtreecommitdiffstats
path: root/test/core_plugins.mk
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2015-09-11 13:27:04 +0200
committerLoïc Hoguin <[email protected]>2015-09-11 13:27:04 +0200
commitb09119c27893528d7a9d51ca29c0c5e2f8fbaa70 (patch)
tree4a3210dc94318622b0a527605ea4cfd7c602bc82 /test/core_plugins.mk
parent561a12fec48f453da5fc6f03fe886e02e93d9e79 (diff)
downloaderlang.mk-b09119c27893528d7a9d51ca29c0c5e2f8fbaa70.tar.gz
erlang.mk-b09119c27893528d7a9d51ca29c0c5e2f8fbaa70.tar.bz2
erlang.mk-b09119c27893528d7a9d51ca29c0c5e2f8fbaa70.zip
Add tests for external plugins
Diffstat (limited to 'test/core_plugins.mk')
-rw-r--r--test/core_plugins.mk76
1 files changed, 76 insertions, 0 deletions
diff --git a/test/core_plugins.mk b/test/core_plugins.mk
new file mode 100644
index 0000000..632585a
--- /dev/null
+++ b/test/core_plugins.mk
@@ -0,0 +1,76 @@
+# Core: External plugins.
+
+CORE_PLUGINS_CASES = all one
+CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES))
+CORE_PLUGINS_CLEAN_TARGETS = $(addprefix clean-,$(CORE_PLUGINS_TARGETS))
+
+.PHONY: core-plugins $(CORE_PLUGINS_TARGETS) clean-core-plugins $(CORE_PLUGINS_CLEAN_TARGETS)
+
+clean-core-plugins: $(CORE_PLUGINS_CLEAN_TARGETS)
+
+$(CORE_PLUGINS_CLEAN_TARGETS):
+ $t rm -rf $(APP_TO_CLEAN)/
+
+core-plugins: $(CORE_PLUGINS_TARGETS)
+
+core-plugins-all: build clean-core-plugins-all
+
+ $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 two plugins"
+ $t mkdir -p $(APP)/plugin_dep/mk
+ $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
+ $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
+ $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
+ $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
+ $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
+# We check that overriding THIS doesn't cause an error.
+ $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
+ $t cd $(APP)/plugin_dep && git init && git add . && git commit -m "Tests"
+
+ $i "Add dependency and plugins to the Makefile"
+ $t sed -i.bak '2i\
+DEPS = plugin_dep\
+dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\
+DEP_PLUGINS = plugin_dep\
+' $(APP)/Makefile
+
+ $i "Run 'make plugin1' and check that it prints plugin1"
+ $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
+
+ $i "Run 'make plugin2' and check that it prints plugin2"
+ $t test -n "`$(MAKE) -C $(APP) plugin2 | grep plugin2`"
+
+core-plugins-one: build clean-core-plugins-one
+
+ $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 two plugins"
+ $t mkdir -p $(APP)/plugin_dep/mk
+ $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
+ $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
+ $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
+ $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
+ $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
+# We check that overriding THIS doesn't cause an error.
+ $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
+ $t cd $(APP)/plugin_dep && git init && git add . && git commit -m "Tests"
+
+ $i "Add dependency and plugins to the Makefile"
+ $t sed -i.bak '2i\
+DEPS = plugin_dep\
+dep_plugin_dep = git file://$(abspath $(APP)/plugin_dep) master\
+DEP_PLUGINS = plugin_dep/mk/plugin1.mk\
+' $(APP)/Makefile
+
+ $i "Run 'make plugin1' and check that it prints plugin1"
+ $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
+
+ $i "Run 'make plugin2' and confirm the target doesn't exist"
+ $t if `$(MAKE) -C $(APP) plugin2`; then false; fi