core_plugins.mk 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # Core: External plugins.
  2. CORE_PLUGINS_CASES = all 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-one: 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 "Create a local git repository with two plugins"
  38. $t mkdir -p $(APP)/plugin_dep/mk
  39. $t echo "plugin1: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin1.mk
  40. $t echo "plugin2: ; @echo \$$@" > $(APP)/plugin_dep/mk/plugin2.mk
  41. $t echo "THIS := \$$(dir \$$(realpath \$$(lastword \$$(MAKEFILE_LIST))))" > $(APP)/plugin_dep/plugins.mk
  42. $t printf "%s\n" "include \$$(THIS)/mk/plugin1.mk" >> $(APP)/plugin_dep/plugins.mk
  43. $t printf "%s\n" "include \$$(THIS)/mk/plugin2.mk" >> $(APP)/plugin_dep/plugins.mk
  44. # We check that overriding THIS doesn't cause an error.
  45. $t echo "THIS :=" >> $(APP)/plugin_dep/plugins.mk
  46. $t cd $(APP)/plugin_dep && \
  47. git init -q && \
  48. git config user.email "testsuite@erlang.mk" && \
  49. git config user.name "test suite" && \
  50. git add . && \
  51. git commit -q --no-gpg-sign -m "Tests"
  52. $i "Add dependency and plugins to the Makefile"
  53. $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
  54. $i "Run 'make plugin1' and check that it prints plugin1"
  55. $t $(MAKE) --no-print-directory -C $(APP) plugin1 | grep -qw plugin1
  56. $i "Run 'make plugin2' and confirm the target doesn't exist"
  57. $t ! $(MAKE) --no-print-directory -C $(APP) plugin2
  58. core-plugins-templates: build clean
  59. $i "Bootstrap a new OTP library named $(APP)"
  60. $t mkdir $(APP)/
  61. $t cp ../erlang.mk $(APP)/
  62. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  63. $i "Create a local git repository with a plugin containing a template"
  64. $t mkdir -p $(APP)/plugin_dep
  65. $t printf "%s\n" \
  66. "define tpl_test_mk" \
  67. "-module(test_mk)." \
  68. "endef" > $(APP)/plugin_dep/plugins.mk
  69. $t cd $(APP)/plugin_dep && \
  70. git init -q && \
  71. git config user.email "testsuite@erlang.mk" && \
  72. git config user.name "test suite" && \
  73. git add . && \
  74. git commit -q --no-gpg-sign -m "Tests"
  75. $i "Add dependency and plugins to the Makefile"
  76. $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
  77. $i "Run 'make list-templates' and check that it prints test_mk"
  78. $t $(MAKE) --no-print-directory -C $(APP) list-templates | grep -qw test_mk
  79. $i "Create a new file using the template"
  80. $t $(MAKE) --no-print-directory -C $(APP) new t=test_mk n=test_mk
  81. $i "Confirm the file exists"
  82. $t test -f $(APP)/src/test_mk.erl
  83. $i "Build the application"
  84. $t $(MAKE) -C $(APP) $v
  85. $i "Check that the file was compiled correctly"
  86. $t test -f $(APP)/ebin/test_mk.beam
  87. core-plugins-test: build clean
  88. $i "Bootstrap a new OTP library named $(APP)"
  89. $t mkdir $(APP)/
  90. $t cp ../erlang.mk $(APP)/
  91. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  92. $i "Write external plugin touch_plugin"
  93. $t mkdir $(APP)/touch_plugin
  94. $t echo -e "app::" >> $(APP)/touch_plugin/plugins.mk
  95. $t echo -e "\ttouch markerfile" >> $(APP)/touch_plugin/plugins.mk
  96. $t echo -e "test-build:: app" >> $(APP)/touch_plugin/plugins.mk
  97. $t echo -e "clean::" >> $(APP)/touch_plugin/plugins.mk
  98. $t echo -e "\trm -f markerfile" >> $(APP)/touch_plugin/plugins.mk
  99. $i "Inject external plugin dependencies into $(APP)"
  100. $t echo 'BUILD_DEPS = touch_plugin' >>$(APP)/Makefile.tmp
  101. $t echo 'DEP_PLUGINS = touch_plugin' >>$(APP)/Makefile.tmp
  102. $t echo 'dep_touch_plugin = cp touch_plugin' >>$(APP)/Makefile.tmp
  103. $t cat $(APP)/Makefile >>$(APP)/Makefile.tmp
  104. $t mv $(APP)/Makefile.tmp $(APP)/Makefile
  105. $i "Build the application"
  106. $t $(MAKE) -C $(APP) $v
  107. $i "Check that the application was compiled correctly"
  108. $t test -e $(APP)/markerfile
  109. $i "Clean the application"
  110. $t $(MAKE) -C $(APP) clean $v
  111. $i "Check that the application was cleaned correctly"
  112. $t test ! -e $(APP)/markerfile
  113. $i "Run tests"
  114. $t $(MAKE) -C $(APP) tests $v
  115. $i "Check that the application was compiled correctly"
  116. $t test -e $(APP)/markerfile