core_upgrade.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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-conflicting-configs: build clean
  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 modify it"
  11. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  12. $t echo core/core > $(APP)/alt-erlangmk-repo/build.config
  13. $t (cd $(APP)/alt-erlangmk-repo && \
  14. git checkout -q -b test-modified-build.config && \
  15. git config user.email "testsuite@erlang.mk" && \
  16. git config user.name "test suite" && \
  17. git commit -q --no-gpg-sign -a -m 'Modify build.config' && \
  18. git checkout master)
  19. $i "Point application to an alternate erlang.mk repository"
  20. $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
  21. $i "Create a custom build.config file without plugins"
  22. $t echo "core/*" > $(APP)/build.config
  23. $i "Upgrade Erlang.mk"
  24. $t $(MAKE) -C $(APP) erlang-mk $v
  25. $i "Check that the bootstrap plugin is gone"
  26. $t ! $(MAKE) -C $(APP) list-templates $v
  27. core-upgrade-custom-build-dir: build clean
  28. $i "Bootstrap a new OTP library named $(APP)"
  29. $t mkdir $(APP)/
  30. $t cp ../erlang.mk $(APP)/
  31. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  32. $i "Append a rule to the Erlang.mk file for testing purposes"
  33. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  34. $i "Check that the test rule works as intended"
  35. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  36. $i "Create the custom build directory"
  37. $t mkdir $(APP)/custom/
  38. $t test -d $(APP)/custom/
  39. $i "Upgrade Erlang.mk with a custom build directory"
  40. $t ERLANG_MK_BUILD_DIR=custom $(MAKE) -C $(APP) erlang-mk $v
  41. $i "Check that the rule is gone"
  42. $t ! $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v
  43. $i "Check that the custom build directory is gone"
  44. $t test ! -d $(APP)/custom/
  45. core-upgrade-custom-config: build clean
  46. $i "Bootstrap a new OTP library named $(APP)"
  47. $t mkdir $(APP)/
  48. $t cp ../erlang.mk $(APP)/
  49. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  50. $i "Create a custom build.config file without plugins"
  51. $t echo "core/*" > $(APP)/build.config
  52. $i "Upgrade Erlang.mk"
  53. $t $(MAKE) -C $(APP) erlang-mk $v
  54. $i "Check that the bootstrap plugin is gone"
  55. $t ! $(MAKE) -C $(APP) list-templates $v
  56. core-upgrade-custom-repo: build clean
  57. $i "Bootstrap a new OTP library named $(APP)"
  58. $t mkdir $(APP)/
  59. $t cp ../erlang.mk $(APP)/
  60. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  61. $i "Fork erlang.mk locally and modify it"
  62. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  63. $t perl -ni.bak -e 'if ($$.==1) {print "# Copyright (c) erlang.mk Testsuite!\n";print}' $(APP)/alt-erlangmk-repo/core/core.mk
  64. $t (cd $(APP)/alt-erlangmk-repo && \
  65. git checkout -q -b test-copyright && \
  66. git config user.email "testsuite@erlang.mk" && \
  67. git config user.name "test suite" && \
  68. git commit -q --no-gpg-sign -a -m 'Add Testsuite copyright' && \
  69. git checkout master)
  70. $i "Point application to an alternate erlang.mk repository"
  71. $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
  72. $i "Update erlang.mk"
  73. $t $(MAKE) -C $(APP) erlang-mk $v
  74. $i "Check our modification is there"
  75. $t grep -q "# Copyright (c) erlang.mk Testsuite!" $(APP)/erlang.mk
  76. core-upgrade-no-config: build clean
  77. $i "Bootstrap a new OTP library named $(APP)"
  78. $t mkdir $(APP)/
  79. $t cp ../erlang.mk $(APP)/
  80. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  81. $i "Append a rule to the Erlang.mk file for testing purposes"
  82. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  83. $i "Check that the test rule works as intended"
  84. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  85. $i "Upgrade Erlang.mk"
  86. $t $(MAKE) -C $(APP) erlang-mk $v
  87. $i "Check that the rule is gone"
  88. $t ! $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v
  89. core-upgrade-renamed-config: build clean
  90. $i "Bootstrap a new OTP library named $(APP)"
  91. $t mkdir $(APP)/
  92. $t cp ../erlang.mk $(APP)/
  93. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  94. $i "Create a custom build.config file without plugins; name it my.build.config"
  95. $t echo "core/*" > $(APP)/my.build.config
  96. $i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
  97. $t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile
  98. $i "Upgrade Erlang.mk"
  99. $t $(MAKE) -C $(APP) erlang-mk $v
  100. $i "Check that the bootstrap plugin is gone"
  101. $t ! $(MAKE) -C $(APP) list-templates $v