diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/Makefile | 3 | ||||
-rw-r--r-- | test/core_upgrade.mk | 34 | ||||
-rw-r--r-- | test/plugin_bootstrap.mk | 63 |
3 files changed, 96 insertions, 4 deletions
diff --git a/test/Makefile b/test/Makefile index 4779c9f..870f4dc 100644 --- a/test/Makefile +++ b/test/Makefile @@ -61,6 +61,7 @@ OTP_MASTER = https://raw.githubusercontent.com/erlang/otp/master # V=1: Show test commands. # V=2: Also show normal Erlang.mk output. # V=3: Also show verbose Erlang.mk output. +# V=4: Also show a trace of each command after expansion. V ?= 0 @@ -82,7 +83,7 @@ else ifeq ($V,2) i = @echo == $@: else t = - v = V=1 + v = V=$(shell echo $$(($(V)-2))) i = @echo == $@: endif diff --git a/test/core_upgrade.mk b/test/core_upgrade.mk index c4a8725..60adaab 100644 --- a/test/core_upgrade.mk +++ b/test/core_upgrade.mk @@ -1,6 +1,6 @@ # Core: Erlang.mk upgrade. -CORE_UPGRADE_CASES = custom-build-dir custom-config custom-repo no-config renamed-config +CORE_UPGRADE_CASES = conflicting-configs 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)) @@ -13,6 +13,35 @@ $(CORE_UPGRADE_CLEAN_TARGETS): core-upgrade: $(CORE_UPGRADE_TARGETS) +core-upgrade-conflicting-configs: build clean-core-upgrade-conflicting-configs + + $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 echo core/core > $(APP)/alt-erlangmk-repo/build.config + $t (cd $(APP)/alt-erlangmk-repo && \ + git checkout -q -b test-modified-build.config && \ + git config user.email "[email protected]" && \ + git config user.name "test suite" && \ + git commit -q -a -m 'Modify build.config' && \ + git checkout master) + + $i "Point application to an alternate erlang.mk repository" + $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 + + $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 ! $(MAKE) -C $(APP) list-templates $v + core-upgrade-custom-build-dir: build clean-core-upgrade-custom-build-dir $i "Bootstrap a new OTP library named $(APP)" @@ -69,7 +98,8 @@ core-upgrade-custom-repo: build clean-core-upgrade-custom-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') + git commit -q -a -m 'Add Testsuite copyright' && \ + git checkout master) $i "Point application to an alternate erlang.mk repository" $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 diff --git a/test/plugin_bootstrap.mk b/test/plugin_bootstrap.mk index 16bfb58..47a81d1 100644 --- a/test/plugin_bootstrap.mk +++ b/test/plugin_bootstrap.mk @@ -1,6 +1,6 @@ # Bootstrap plugin. -BOOTSTRAP_CASES = app lib rel templates +BOOTSTRAP_CASES = app lib rel sp tab templates BOOTSTRAP_TARGETS = $(addprefix bootstrap-,$(BOOTSTRAP_CASES)) BOOTSTRAP_CLEAN_TARGETS = $(addprefix clean-,$(BOOTSTRAP_TARGETS)) @@ -116,6 +116,67 @@ endif $i "Check that there's no erl_crash.dump file" $t test ! -f $(APP)/_rel/$(APP)_release/erl_crash.dump +bootstrap-sp: build clean-bootstrap-sp + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap SP=2 $v + + $i "Check that all bootstrapped files exist" + $t test -f $(APP)/Makefile +ifdef LEGACY + $t test -f $(APP)/src/$(APP).app.src +endif + $t test -f $(APP)/src/$(APP)_app.erl + $t test -f $(APP)/src/$(APP)_sup.erl + + $i "Check that bootstrapped files have no tabs" +ifdef LEGACY + $t test -z "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP).app.src`" +endif + $t test -z "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_app.erl`" + $t test -z "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_sup.erl`" + +# Everything looks OK, but let's compile the application to make sure. + $i "Build the application" + $t $(MAKE) -C $(APP) $v + + $i "Check that all compiled files exist" + $t test -f $(APP)/ebin/$(APP).app + $t test -f $(APP)/ebin/$(APP)_app.beam + $t test -f $(APP)/ebin/$(APP)_sup.beam + + $i "Check that the application was compiled correctly" + $t $(ERL) -pa $(APP)/ebin/ -eval " \ + ok = application:start($(APP)), \ + {ok, [$(APP)_app, $(APP)_sup]} = application:get_key($(APP), modules), \ + {module, $(APP)_app} = code:load_file($(APP)_app), \ + {module, $(APP)_sup} = code:load_file($(APP)_sup), \ + halt()" + +bootstrap-tab: build clean-bootstrap-tab + + $i "Bootstrap a new OTP application named $(APP)" + $t mkdir $(APP)/ + $t cp ../erlang.mk $(APP)/ + $t $(MAKE) -C $(APP) -f erlang.mk bootstrap $v + + $i "Check that all bootstrapped files exist" + $t test -f $(APP)/Makefile +ifdef LEGACY + $t test -f $(APP)/src/$(APP).app.src +endif + $t test -f $(APP)/src/$(APP)_app.erl + $t test -f $(APP)/src/$(APP)_sup.erl + + $i "Check that bootstrapped files have tabs" +ifdef LEGACY + $t test "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP).app.src`" +endif + $t test "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_app.erl`" + $t test "`awk -F "\t" 'NF > 1' $(APP)/src/$(APP)_sup.erl`" + bootstrap-templates: build clean-bootstrap-templates $i "Bootstrap a new OTP library named $(APP)" |