core_upgrade.mk 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. # Core: Erlang.mk upgrade.
  2. CORE_UPGRADE_TARGETS = $(call list_targets,core-upgrade)
  3. .PHONY: core-upgrade $(CORE_UPGRADE_TARGETS)
  4. core-upgrade: $(CORE_UPGRADE_TARGETS)
  5. core-upgrade-changelog: init
  6. $i "Bootstrap a new OTP library named $(APP)"
  7. $t mkdir $(APP)/
  8. $t cp ../erlang.mk $(APP)/
  9. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  10. $i "Fork erlang.mk locally and set a test CHANGELOG.asciidoc"
  11. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  12. $t echo "$(APP)$(APP)" > $(APP)/alt-erlangmk-repo/CHANGELOG.asciidoc
  13. # Since part of this functionality needs the main Makefile, copy it.
  14. $t cp ../Makefile $(APP)/alt-erlangmk-repo/
  15. $t (cd $(APP)/alt-erlangmk-repo && \
  16. git config user.email "testsuite@erlang.mk" && \
  17. git config user.name "test suite" && \
  18. git add CHANGELOG.asciidoc Makefile && \
  19. git commit -q --no-gpg-sign -a -m 'Add test changelog')
  20. $i "Point application to an alternate erlang.mk repository"
  21. $t perl -ni.bak -e 'print;if ($$.==1) {print "ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\n"}' $(APP)/Makefile
  22. $i "Update erlang.mk; CHANGELOG.asciidoc should be printed"
  23. $t $(MAKE) -C $(APP) erlang-mk | grep -c "$(APP)$(APP)" | grep -q 1
  24. core-upgrade-conflicting-configs: init
  25. $i "Bootstrap a new OTP library named $(APP)"
  26. $t mkdir $(APP)/
  27. $t cp ../erlang.mk $(APP)/
  28. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  29. $i "Fork erlang.mk locally and modify it"
  30. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  31. $t echo core/core > $(APP)/alt-erlangmk-repo/build.config
  32. $t (cd $(APP)/alt-erlangmk-repo && \
  33. git checkout -q -b test-modified-build.config && \
  34. git config user.email "testsuite@erlang.mk" && \
  35. git config user.name "test suite" && \
  36. git commit -q --no-gpg-sign -a -m 'Modify build.config' && \
  37. git checkout master)
  38. $i "Point application to an alternate erlang.mk repository"
  39. $t perl -ni.bak -e 'print;if ($$.==1) {print "ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\nERLANG_MK_COMMIT = test-modified-build.config\n"}' $(APP)/Makefile
  40. $i "Create a custom build.config file without plugins"
  41. $t echo "core/*" > $(APP)/build.config
  42. $i "Upgrade Erlang.mk"
  43. $t $(MAKE) -C $(APP) erlang-mk $v
  44. $i "Check that the bootstrap plugin is gone"
  45. $t ! $(MAKE) -C $(APP) list-templates $v
  46. core-upgrade-custom-build-dir: init
  47. $i "Bootstrap a new OTP library named $(APP)"
  48. $t mkdir $(APP)/
  49. $t cp ../erlang.mk $(APP)/
  50. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  51. $i "Append a rule to the Erlang.mk file for testing purposes"
  52. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  53. $i "Check that the test rule works as intended"
  54. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  55. $i "Create the custom build directory"
  56. $t mkdir $(APP)/custom/
  57. $t test -d $(APP)/custom/
  58. $i "Upgrade Erlang.mk with a custom build directory"
  59. $t ERLANG_MK_BUILD_DIR=custom $(MAKE) -C $(APP) erlang-mk $v
  60. $i "Check that the rule is gone"
  61. $t ! $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v
  62. $i "Check that the custom build directory is gone"
  63. $t test ! -d $(APP)/custom/
  64. core-upgrade-custom-config: init
  65. $i "Bootstrap a new OTP library named $(APP)"
  66. $t mkdir $(APP)/
  67. $t cp ../erlang.mk $(APP)/
  68. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  69. $i "Create a custom build.config file without plugins"
  70. $t echo "core/*" > $(APP)/build.config
  71. $i "Upgrade Erlang.mk"
  72. $t $(MAKE) -C $(APP) erlang-mk $v
  73. $i "Check that the bootstrap plugin is gone"
  74. $t ! $(MAKE) -C $(APP) list-templates $v
  75. core-upgrade-custom-repo: init
  76. $i "Bootstrap a new OTP library named $(APP)"
  77. $t mkdir $(APP)/
  78. $t cp ../erlang.mk $(APP)/
  79. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  80. $i "Fork erlang.mk locally and modify it"
  81. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  82. $t perl -ni.bak -e 'if ($$.==1) {print "# Copyright (c) erlang.mk Testsuite!\n";print}' $(APP)/alt-erlangmk-repo/core/core.mk
  83. $t (cd $(APP)/alt-erlangmk-repo && \
  84. git checkout -q -b test-copyright && \
  85. git config user.email "testsuite@erlang.mk" && \
  86. git config user.name "test suite" && \
  87. git commit -q --no-gpg-sign -a -m 'Add Testsuite copyright' && \
  88. git checkout master)
  89. $i "Point application to an alternate erlang.mk repository"
  90. $t perl -ni.bak -e 'print;if ($$.==1) {print "ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\nERLANG_MK_COMMIT = test-copyright\n"}' $(APP)/Makefile
  91. $i "Update erlang.mk"
  92. $t $(MAKE) -C $(APP) erlang-mk $v
  93. $i "Check our modification is there"
  94. $t grep -q "# Copyright (c) erlang.mk Testsuite!" $(APP)/erlang.mk
  95. core-upgrade-delete-tmp-dir: init
  96. $i "Bootstrap a new OTP library named $(APP)"
  97. $t mkdir $(APP)/
  98. $t cp ../erlang.mk $(APP)/
  99. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  100. $i "Build the application"
  101. $t $(MAKE) -C $(APP) $v
  102. $i "Check that the .erlang.mk directory exists"
  103. $t test -e $(APP)/.erlang.mk/
  104. $i "Upgrade Erlang.mk"
  105. $t $(MAKE) -C $(APP) erlang-mk $v
  106. $i "Check that the .erlang.mk directory was removed"
  107. $t ! test -e $(APP)/.erlang.mk/
  108. core-upgrade-no-config: init
  109. $i "Bootstrap a new OTP library named $(APP)"
  110. $t mkdir $(APP)/
  111. $t cp ../erlang.mk $(APP)/
  112. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  113. $i "Append a rule to the Erlang.mk file for testing purposes"
  114. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  115. $i "Check that the test rule works as intended"
  116. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  117. $i "Upgrade Erlang.mk"
  118. $t $(MAKE) -C $(APP) erlang-mk $v
  119. $i "Check that the rule is gone"
  120. $t ! $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v
  121. core-upgrade-renamed-config: init
  122. $i "Bootstrap a new OTP library named $(APP)"
  123. $t mkdir $(APP)/
  124. $t cp ../erlang.mk $(APP)/
  125. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  126. $i "Create a custom build.config file without plugins; name it my.build.config"
  127. $t echo "core/*" > $(APP)/my.build.config
  128. $i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
  129. $t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile
  130. $i "Upgrade Erlang.mk"
  131. $t $(MAKE) -C $(APP) erlang-mk $v
  132. $i "Check that the bootstrap plugin is gone"
  133. $t ! $(MAKE) -C $(APP) list-templates $v