core_plugins.mk 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. # Core: External plugins.
  2. CORE_PLUGINS_CASES = all early one templates test
  3. CORE_PLUGINS_TARGETS = $(addprefix core-plugins-,$(CORE_PLUGINS_CASES))
  4. .PHONY: core-plugins $(CORE_PLUGINS_TARGETS)
  5. core-plugins: $(CORE_PLUGINS_TARGETS)
  6. core-plugins-all: build clean
  7. $i "Bootstrap a new OTP library named $(APP)"
  8. $t mkdir $(APP)/
  9. $t cp ../erlang.mk $(APP)/
  10. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  11. $i "Create a local git repository with two plugins"
  12. $t mkdir -p $(APP)/plugin_dep/mk
  13. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  14. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  15. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  16. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  17. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  18. # We check that overriding THIS doesn't cause an error.
  19. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  20. $t cd $(APP)/plugin_dep && \
  21. git init -q && \
  22. git config user.email "testsuite@erlang.mk" && \
  23. git config user.name "test suite" && \
  24. git add . && \
  25. git commit -q --no-gpg-sign -m "Tests"
  26. $i "Add dependency and plugins to the Makefile"
  27. $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
  28. $i "Run 'make plugin1' and check that it prints plugin1"
  29. $t test -n "`$(MAKE) -C $(APP) plugin1 | grep plugin1`"
  30. $i "Run 'make plugin2' and check that it prints plugin2"
  31. $t test -n "`$(MAKE) -C $(APP) plugin2 | grep plugin2`"
  32. core-plugins-early: build clean
  33. $i "Bootstrap a new OTP library named $(APP)"
  34. $t mkdir $(APP)/
  35. $t cp ../erlang.mk $(APP)/
  36. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  37. $i "Write external plugin adddep_plugin"
  38. $t mkdir $(APP)/adddep_plugin
  39. $t echo -e "DEPS += cowlib" >> $(APP)/adddep_plugin/early-plugins.mk
  40. $i "Inject external plugin dependencies into $(APP)"
  41. $t echo 'DEPS = ranch' >>$(APP)/Makefile.tmp
  42. $t echo 'BUILD_DEPS = adddep_plugin' >>$(APP)/Makefile.tmp
  43. $t echo 'DEP_EARLY_PLUGINS = adddep_plugin' >>$(APP)/Makefile.tmp
  44. $t echo 'dep_adddep_plugin = cp adddep_plugin' >>$(APP)/Makefile.tmp
  45. $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp
  46. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  47. $i "Build the application"
  48. $t $(MAKE) -C $(APP) $v
  49. $i "Check that all dependencies were fetched"
  50. $t test -e $(APP)/deps/cowlib
  51. $t test -e $(APP)/deps/ranch
  52. core-plugins-one: build clean
  53. $i "Bootstrap a new OTP library named $(APP)"
  54. $t mkdir $(APP)/
  55. $t cp ../erlang.mk $(APP)/
  56. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  57. $i "Create a local git repository with two plugins"
  58. $t mkdir -p $(APP)/plugin_dep/mk
  59. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  60. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  61. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  62. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  63. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  64. # We check that overriding THIS doesn't cause an error.
  65. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  66. $t cd $(APP)/plugin_dep && \
  67. git init -q && \
  68. git config user.email "testsuite@erlang.mk" && \
  69. git config user.name "test suite" && \
  70. git add . && \
  71. git commit -q --no-gpg-sign -m "Tests"
  72. $i "Add dependency and plugins to the Makefile"
  73. $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/mk/plugin1.mk\n"}' $(APP)/Makefile
  74. $i "Run 'make plugin1' and check that it prints plugin1"
  75. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  76. $i "Run 'make plugin2' and confirm the target doesn't exist"
  77. $t ! $(MAKE) --no-print-directory -C $(APP) plugin2
  78. core-plugins-templates: build clean
  79. $i "Bootstrap a new OTP library named $(APP)"
  80. $t mkdir $(APP)/
  81. $t cp ../erlang.mk $(APP)/
  82. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  83. $i "Create a local git repository with a plugin containing a template"
  84. $t mkdir -p $(APP)/plugin_dep
  85. $t printf "%s\n" \
  86. "define tpl_test_mk" \
  87. "-module(test_mk)." \
  88. "endef" > $(APP)/plugin_dep/plugins.mk
  89. $t cd $(APP)/plugin_dep && \
  90. git init -q && \
  91. git config user.email "testsuite@erlang.mk" && \
  92. git config user.name "test suite" && \
  93. git add . && \
  94. git commit -q --no-gpg-sign -m "Tests"
  95. $i "Add dependency and plugins to the Makefile"
  96. $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
  97. $i "Run 'make list-templates' and check that it prints test_mk"
  98. $t $(MAKE) --no-print-directory -C $(APP) list-templates | grep -qw test_mk
  99. $i "Create a new file using the template"
  100. $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk
  101. $i "Confirm the file exists"
  102. $t test -f $(APP)/src/test_mk.erl
  103. $i "Build the application"
  104. $t $(MAKE) -C $(APP) $v
  105. $i "Check that the file was compiled correctly"
  106. $t test -f $(APP)/ebin/test_mk.beam
  107. core-plugins-test: build clean
  108. $i "Bootstrap a new OTP library named $(APP)"
  109. $t mkdir $(APP)/
  110. $t cp ../erlang.mk $(APP)/
  111. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  112. $i "Write external plugin touch_plugin"
  113. $t mkdir $(APP)/touch_plugin
  114. $t echo -e "app::" >> $(APP)/touch_plugin/plugins.mk
  115. $t echo -e "\ttouch markerfile" >> $(APP)/touch_plugin/plugins.mk
  116. $t echo -e "test-build:: app" >> $(APP)/touch_plugin/plugins.mk
  117. $t echo -e "clean::" >> $(APP)/touch_plugin/plugins.mk
  118. $t echo -e "\trm -f markerfile" >> $(APP)/touch_plugin/plugins.mk
  119. $i "Inject external plugin dependencies into $(APP)"
  120. $t echo 'BUILD_DEPS = touch_plugin' >>$(APP)/Makefile.tmp
  121. $t echo 'DEP_PLUGINS = touch_plugin' >>$(APP)/Makefile.tmp
  122. $t echo 'dep_touch_plugin = cp touch_plugin' >>$(APP)/Makefile.tmp
  123. $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp
  124. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  125. $i "Build the application"
  126. $t $(MAKE) -C $(APP) $v
  127. $i "Check that the application was compiled correctly"
  128. $t test -e $(APP)/markerfile
  129. $i "Clean the application"
  130. $t $(MAKE) -C $(APP) clean $v
  131. $i "Check that the application was cleaned correctly"
  132. $t test ! -e $(APP)/markerfile
  133. $i "Run tests"
  134. $t $(MAKE) -C $(APP) tests $v
  135. $i "Check that the application was compiled correctly"
  136. $t test -e $(APP)/markerfile