core_upgrade.mk 4.9 KB

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