From 0a793ac13a27ba940b35aaf2928f8ca42d964908 Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Tue, 9 May 2017 13:35:43 +0100 Subject: [PATCH] Only create clonemap when zuul-cloner is used In test environments outside of OpenStack-CI, it is preferred that a file is not created and deleted in the user home directory, especially if it is not used. Change-Id: I5da7802d61d2ab6b03908138e3a3ed2db22e3d29 --- tests/tests-repo-clone.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/tests/tests-repo-clone.sh b/tests/tests-repo-clone.sh index 619a9055..9c793c59 100755 --- a/tests/tests-repo-clone.sh +++ b/tests/tests-repo-clone.sh @@ -34,28 +34,39 @@ export TESTING_HOME=${TESTING_HOME:-$HOME} export WORKING_DIR=${WORKING_DIR:-$(pwd)} export CLONE_UPGRADE_TESTS=${CLONE_UPGRADE_TESTS:-no} -## Main ---------------------------------------------------------------------- +## Functions ----------------------------------------------------------------- + +function create_tests_clonemap { # Prepare the clonemap for zuul-cloner to use -# This is placed here instead of inside the conditional -# to prevent indentation problems. cat > ${TESTING_HOME}/tests-clonemap.yaml << EOF clonemap: - name: openstack/openstack-ansible-tests dest: ${WORKING_DIR}/tests/common EOF +} + +## Main ---------------------------------------------------------------------- + # If zuul-cloner is present, use it so that we # also include any dependent patches from the # tests repo noted in the commit message. if [[ -x /usr/zuul-env/bin/zuul-cloner ]]; then + # Prepare the clonemap for zuul-cloner to use + create_tests_clonemap + + # Execute the clone /usr/zuul-env/bin/zuul-cloner \ --cache-dir /opt/git \ --map ${TESTING_HOME}/tests-clonemap.yaml \ git://git.openstack.org \ openstack/openstack-ansible-tests + # Clean up the clonemap. + rm -f ${TESTING_HOME}/tests-clonemap.yaml + # Alternatively, use a simple git-clone. We do # not re-clone if the directory exists already # to prevent overwriting any local changes which @@ -73,9 +84,6 @@ elif [[ ! -d tests/common ]]; then fi fi -# Clean up the clonemap. -rm -f ${TESTING_HOME}/tests-clonemap.yaml - # If this test set includes an upgrade test, the # previous stable release tests repo must also be # cloned.