core_upgrade.mk 5.3 KB

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