core_upgrade.mk 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. # Core: Erlang.mk upgrade.
  2. CORE_UPGRADE_CASES = 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-custom-build-dir: build clean-core-upgrade-custom-build-dir
  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 "Append a rule to the Erlang.mk file for testing purposes"
  16. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  17. $i "Check that the test rule works as intended"
  18. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  19. $i "Create the custom build directory"
  20. $t mkdir $(APP)/custom/
  21. $t test -d $(APP)/custom/
  22. $i "Upgrade Erlang.mk with a custom build directory"
  23. $t ERLANG_MK_BUILD_DIR=custom $(MAKE) -C $(APP) erlang-mk $v
  24. $i "Check that the rule is gone"
  25. $t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi
  26. $i "Check that the custom build directory is gone"
  27. $t test ! -d $(APP)/custom/
  28. core-upgrade-custom-config: build clean-core-upgrade-custom-config
  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 "Create a custom build.config file without plugins"
  34. $t echo "core/*" > $(APP)/build.config
  35. $i "Upgrade Erlang.mk"
  36. $t $(MAKE) -C $(APP) erlang-mk $v
  37. $i "Check that the bootstrap plugin is gone"
  38. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi
  39. core-upgrade-custom-repo: build clean-core-upgrade-custom-repo
  40. $i "Bootstrap a new OTP library named $(APP)"
  41. $t mkdir $(APP)/
  42. $t cp ../erlang.mk $(APP)/
  43. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  44. $i "Fork erlang.mk locally and modify it"
  45. $t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
  46. $t sed -i.bak '1i\
  47. # Copyright (c) erlang.mk Testsuite!\
  48. ' $(APP)/alt-erlangmk-repo/core/core.mk
  49. $t (cd $(APP)/alt-erlangmk-repo && \
  50. git checkout -q -b test-copyright && \
  51. git config user.email "testsuite@erlang.mk" && \
  52. git config user.name "test suite" && \
  53. git commit -q -a -m 'Add Testsuite copyright')
  54. $i "Point application to an alternate erlang.mk repository"
  55. $t sed -i.bak '2i\
  56. ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\
  57. ERLANG_MK_COMMIT = test-copyright\
  58. ' $(APP)/Makefile
  59. $i "Update erlang.mk"
  60. $t $(MAKE) -C $(APP) erlang-mk $v
  61. $i "Check our modification is there"
  62. $t grep -q "# Copyright (c) erlang.mk Testsuite!" $(APP)/erlang.mk
  63. core-upgrade-no-config: build clean-core-upgrade-no-config
  64. $i "Bootstrap a new OTP library named $(APP)"
  65. $t mkdir $(APP)/
  66. $t cp ../erlang.mk $(APP)/
  67. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  68. $i "Append a rule to the Erlang.mk file for testing purposes"
  69. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  70. $i "Check that the test rule works as intended"
  71. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  72. $i "Upgrade Erlang.mk"
  73. $t $(MAKE) -C $(APP) erlang-mk $v
  74. $i "Check that the rule is gone"
  75. $t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi
  76. core-upgrade-renamed-config: build clean-core-upgrade-renamed-config
  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 "Create a custom build.config file without plugins; name it my.build.config"
  82. $t echo "core/*" > $(APP)/my.build.config
  83. $i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
  84. $t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile
  85. $i "Upgrade Erlang.mk"
  86. $t $(MAKE) -C $(APP) erlang-mk $v
  87. $i "Check that the bootstrap plugin is gone"
  88. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi