Making run_test.sh python version and directory

agnostic

Refactored some of the shell scripts to handle
being run from another directory, as well as to
not force the use of 2.6

edit: format the comments

Change-Id: Id92b9dc82743598b7c570e431cad423c8a2ee95d
This commit is contained in:
Aaron Lee 2011-10-18 10:27:02 -05:00
parent 2355a4b036
commit 78dbb64366
3 changed files with 35 additions and 29 deletions

View File

@ -33,8 +33,9 @@ function process_option {
esac
}
base_dir=$(dirname $0)
venv=.kong-venv
with_venv=tools/with_venv.sh
with_venv=../tools/with_venv.sh
always_venv=0
never_venv=0
force=0
@ -59,35 +60,38 @@ function run_pep8 {
${wrapper} pep8 $PEP8_OPTIONS $PEP8_INCLUDE || exit 1
}
NOSETESTS="env python run_tests.py $noseargs"
if [ $never_venv -eq 0 ]
then
# Remove the virtual environment if --force used
if [ $force -eq 1 ]; then
echo "Cleaning virtualenv..."
rm -rf ${venv}
fi
if [ -e ${venv} ]; then
wrapper="${with_venv}"
else
if [ $always_venv -eq 1 ]; then
# Automatically install the virtualenv
use_ve='y'
else
echo -e "No virtual environment found...create one? (Y/n) \c"
read use_ve
function setup_venv {
if [ $never_venv -eq 0 ]
then
# Remove the virtual environment if --force used
if [ $force -eq 1 ]; then
echo "Cleaning virtualenv..."
rm -rf ${venv}
fi
if [ -e ${venv} ]; then
wrapper="${with_venv}"
else
if [ $always_venv -eq 1 ]; then
# Automatically install the virtualenv
use_ve='y'
else
echo -e "No virtual environment found...create one? (Y/n) \c"
read use_ve
fi
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
# Install the virtualenv and run the test suite in it
env python ../tools/install_venv.py
wrapper=${with_venv}
fi
fi
fi
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
# Install the virtualenv and run the test suite in it
env python ../tools/install_venv.py
wrapper=${with_venv}
fi
fi
fi
}
if [ $just_pep8 -eq 1 ]; then
run_pep8
exit
fi
cd $base_dir
setup_venv
run_tests || exit

View File

@ -26,15 +26,15 @@ done
echo $test_opts
function run_tests {
base_dir=$(dirname $0)
for test_dir in $tests
do
cd $test_dir
test_cmd="./run_tests.sh ${test_opts}"
test_cmd="${base_dir}/${test_dir}/run_tests.sh ${test_opts}"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo $test_cmd
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
$test_cmd
cd ..
done
}

View File

@ -96,8 +96,10 @@ def install_dependencies(venv=VENV):
run_command([venv_tool, 'pip', 'install', '-E', venv, '-r', PIP_REQUIRES],
redirect_output=False)
python_version = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
# Tell the virtual env how to "import glance"
pthfile = os.path.join(venv, "lib", "python2.6", "site-packages",
pthfile = os.path.join(venv, "lib", python_version, "site-packages",
"glance.pth")
f = open(pthfile, 'w')
f.write("%s\n" % ROOT)