From ffba4c451fc484cb59e4cfea6d03347895d11ec0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Tue, 17 Nov 2015 17:26:47 +0100 Subject: make erlang-mk: Copy build.config after switching to $(ERLANG_MK_COMMIT) If the local build.config has changes compared to upstream's master branch, and $(ERLANG_MK_COMMIT) also brings changes to this file, copying the local file to the checkout before switching to $(ERLANG_MK_COMMIT) caused git-checkout(1) to abort with: error: Your local changes to the following files would be overwritten by checkout: build.config Please, commit your changes or stash them before you can switch branches. Aborting While here, fix `core-upgrade-custom-repo` test case: without switching back the alternate erlang.mk repository to its master branch, the clone always got the test-copyright branch by default, making the ERLANG_MK_COMMIT check ineffective. --- core/core.mk | 5 ++++- test/core_upgrade.mk | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/core/core.mk b/core/core.mk index 407b940..4ec72f2 100644 --- a/core/core.mk +++ b/core/core.mk @@ -192,8 +192,11 @@ ERLANG_MK_BUILD_DIR ?= .erlang.mk.build erlang-mk: git clone $(ERLANG_MK_REPO) $(ERLANG_MK_BUILD_DIR) +ifdef ERLANG_MK_COMMIT + cd $(ERLANG_MK_BUILD_DIR) && git checkout $(ERLANG_MK_COMMIT) +endif if [ -f $(ERLANG_MK_BUILD_CONFIG) ]; then cp $(ERLANG_MK_BUILD_CONFIG) $(ERLANG_MK_BUILD_DIR)/build.config; fi - cd $(ERLANG_MK_BUILD_DIR) && $(if $(ERLANG_MK_COMMIT),git checkout $(ERLANG_MK_COMMIT) &&) $(MAKE) + $(MAKE) -C $(ERLANG_MK_BUILD_DIR) cp $(ERLANG_MK_BUILD_DIR)/erlang.mk ./erlang.mk rm -rf $(ERLANG_MK_BUILD_DIR) 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 "testsuite@erlang.mk" && \ + 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 "testsuite@erlang.mk" && \ 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 -- cgit v1.2.3