From 77f9bdf433437d3c93d88673c777f1d2d7317faa Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Fri, 15 Jan 2016 19:22:21 +0100 Subject: [PATCH] Avoid git clone in integration test Allow script to be called with a third argument which is a path to a checked out directory. This allows setting up the repo externally using zuul-cloner in the infra script and allows usage of depends-on. Simplify the script a bit, we can remove the special handling for file and also do not need to give a default argument, this is called from tox. Change-Id: I3b6180b6b274966de63fe281021ff9f4186a929b Needed-By: I828c1875e5f008fa55b693ad210421794395f623 --- integration-test/test.sh | 50 +++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/integration-test/test.sh b/integration-test/test.sh index 5520af4..dfb8af1 100755 --- a/integration-test/test.sh +++ b/integration-test/test.sh @@ -1,32 +1,46 @@ #!/bin/bash -# Usage: test.sh openstack keystone +# Usage: test.sh openstack keystone path-to-repo +# path-to-repo is an optional parameter, if it exists +# no cloning will happen and the local directory will be used, +# the first two parameter get ignored. # Note: you can clone from a local file with REPO_ROOT=file:////~/path/to/repo + set -x set -e REPO_ROOT=${REPO_ROOT:-git://git.openstack.org} -if [[ -z "$2" ]]; then - org=openstack - project=nova + +if [[ $# -lt 2 ]] ; then + echo "Script needs at least two arguments:" + echo "$0 organization name [path-to-repo]" + exit 1 +fi +org=$1 +project=$2 + +if [[ $# -eq 3 ]] ; then + projectdir=$3 + clone=0 else - org=$1 - project=$2 + projectdir=$project + clone=1 fi -tempdir="$(mktemp -d)" +if [ "$clone" = "1" ] ; then -pushd $tempdir - if [[ $REPO_ROOT == file://* ]]; then - git clone $REPO_ROOT/$org/$project - else - git clone $REPO_ROOT/$org/$project --depth=1 - fi + tempdir="$(mktemp -d)" - pushd $project - set +e - flake8 --select H --statistics - popd + trap "rm -rf $tempdir" EXIT + pushd $tempdir + git clone $REPO_ROOT/$org/$project --depth=1 +fi + +pushd $projectdir +set +e +flake8 --select H --statistics popd -rm -rf $tempdir +if [ "$clone" = "1" ] ; then + popd +fi