core_upgrade.mk 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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 perl -ni.bak -e 'if ($$.==1) {print "# Copyright (c) erlang.mk Testsuite!\n";print}' $(APP)/alt-erlangmk-repo/core/core.mk
  47. $t (cd $(APP)/alt-erlangmk-repo && \
  48. git checkout -q -b test-copyright && \
  49. git config user.email "testsuite@erlang.mk" && \
  50. git config user.name "test suite" && \
  51. git commit -q -a -m 'Add Testsuite copyright')
  52. $i "Point application to an alternate erlang.mk repository"
  53. $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
  54. $i "Update erlang.mk"
  55. $t $(MAKE) -C $(APP) erlang-mk $v
  56. $i "Check our modification is there"
  57. $t grep -q "# Copyright (c) erlang.mk Testsuite!" $(APP)/erlang.mk
  58. core-upgrade-no-config: build clean-core-upgrade-no-config
  59. $i "Bootstrap a new OTP library named $(APP)"
  60. $t mkdir $(APP)/
  61. $t cp ../erlang.mk $(APP)/
  62. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  63. $i "Append a rule to the Erlang.mk file for testing purposes"
  64. $t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk
  65. $i "Check that the test rule works as intended"
  66. $t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"
  67. $i "Upgrade Erlang.mk"
  68. $t $(MAKE) -C $(APP) erlang-mk $v
  69. $i "Check that the rule is gone"
  70. $t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi
  71. core-upgrade-renamed-config: build clean-core-upgrade-renamed-config
  72. $i "Bootstrap a new OTP library named $(APP)"
  73. $t mkdir $(APP)/
  74. $t cp ../erlang.mk $(APP)/
  75. $t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v
  76. $i "Create a custom build.config file without plugins; name it my.build.config"
  77. $t echo "core/*" > $(APP)/my.build.config
  78. $i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
  79. $t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile
  80. $i "Upgrade Erlang.mk"
  81. $t $(MAKE) -C $(APP) erlang-mk $v
  82. $i "Check that the bootstrap plugin is gone"
  83. $t if $(MAKE) -C $(APP) list-templates $v; then false; fi