aboutsummaryrefslogtreecommitdiffstats
path: root/test/core_upgrade.mk
blob: ec49a9fc2dc1eae3d1eb61c95c72a3783d6a56b4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Core: Erlang.mk upgrade.

CORE_UPGRADE_CASES = custom-build-dir custom-config custom-repo no-config renamed-config
CORE_UPGRADE_TARGETS = $(addprefix core-upgrade-,$(CORE_UPGRADE_CASES))
CORE_UPGRADE_CLEAN_TARGETS = $(addprefix clean-,$(CORE_UPGRADE_TARGETS))

.PHONY: core-upgrade $(CORE_UPGRADE_TARGETS) clean-core-upgrade $(CORE_UPGRADE_CLEAN_TARGETS)

clean-core-upgrade: $(CORE_UPGRADE_CLEAN_TARGETS)

$(CORE_UPGRADE_CLEAN_TARGETS):
	$t rm -rf $(APP_TO_CLEAN)/

core-upgrade: $(CORE_UPGRADE_TARGETS)

core-upgrade-custom-build-dir: build clean-core-upgrade-custom-build-dir

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Append a rule to the Erlang.mk file for testing purposes"
	$t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk

	$i "Check that the test rule works as intended"
	$t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"

	$i "Create the custom build directory"
	$t mkdir $(APP)/custom/
	$t test -d $(APP)/custom/

	$i "Upgrade Erlang.mk with a custom build directory"
	$t ERLANG_MK_BUILD_DIR=custom $(MAKE) -C $(APP) erlang-mk $v

	$i "Check that the rule is gone"
	$t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi

	$i "Check that the custom build directory is gone"
	$t test ! -d $(APP)/custom/

core-upgrade-custom-config: build clean-core-upgrade-custom-config

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Create a custom build.config file without plugins"
	$t echo "core/*" > $(APP)/build.config

	$i "Upgrade Erlang.mk"
	$t $(MAKE) -C $(APP) erlang-mk $v

	$i "Check that the bootstrap plugin is gone"
	$t if $(MAKE) -C $(APP) list-templates $v; then false; fi

core-upgrade-custom-repo: build clean-core-upgrade-custom-repo

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Fork erlang.mk locally and modify it"
	$t git clone -q https://github.com/ninenines/erlang.mk $(APP)/alt-erlangmk-repo
	$t sed -i.bak '1i\
# Copyright (c) erlang.mk Testsuite!\
' $(APP)/alt-erlangmk-repo/core/core.mk
	$t (cd $(APP)/alt-erlangmk-repo && \
		git checkout -q -b test-copyright && \
		git config user.email "[email protected]" && \
		git config user.name "test suite" && \
		git commit -q -a -m 'Add Testsuite copyright')

	$i "Point application to an alternate erlang.mk repository"
	$t sed -i.bak '2i\
ERLANG_MK_REPO = file://$(abspath $(APP)/alt-erlangmk-repo)\
ERLANG_MK_COMMIT = test-copyright\
' $(APP)/Makefile

	$i "Update erlang.mk"
	$t $(MAKE) -C $(APP) erlang-mk $v

	$i "Check our modification is there"
	$t grep -q "# Copyright (c) erlang.mk Testsuite!" $(APP)/erlang.mk

core-upgrade-no-config: build clean-core-upgrade-no-config

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Append a rule to the Erlang.mk file for testing purposes"
	$t echo "erlang_mk_upgrade_test_rule: ; @echo FAIL" >> $(APP)/erlang.mk

	$i "Check that the test rule works as intended"
	$t test "FAIL" = "`$(MAKE) -C $(APP) --no-print-directory erlang_mk_upgrade_test_rule V=0`"

	$i "Upgrade Erlang.mk"
	$t $(MAKE) -C $(APP) erlang-mk $v

	$i "Check that the rule is gone"
	$t if $(MAKE) -C $(APP) erlang_mk_upgrade_test_rule $v; then false; fi

core-upgrade-renamed-config: build clean-core-upgrade-renamed-config

	$i "Bootstrap a new OTP library named $(APP)"
	$t mkdir $(APP)/
	$t cp ../erlang.mk $(APP)/
	$t $(MAKE) -C $(APP) -f erlang.mk bootstrap-lib $v

	$i "Create a custom build.config file without plugins; name it my.build.config"
	$t echo "core/*" > $(APP)/my.build.config

	$i "Set ERLANG_MK_BUILD_CONFIG=my.build.config in the Makefile"
	$t echo "ERLANG_MK_BUILD_CONFIG = my.build.config" >> $(APP)/Makefile

	$i "Upgrade Erlang.mk"
	$t $(MAKE) -C $(APP) erlang-mk $v

	$i "Check that the bootstrap plugin is gone"
	$t if $(MAKE) -C $(APP) list-templates $v; then false; fi