Optional --no-site-packages in venv

Added a flag to run_tests.sh to allow user to optionally install venv with --no-site-packages.

This fixes bug 880905

Change-Id: Ic645e0ec56c90b72fef526ebc9f55975d446e2ae
This commit is contained in:
Lorin Hochstein 2011-10-30 09:00:59 -04:00
parent 514ccbbfbd
commit a36ffe2b63

View File

@ -8,6 +8,7 @@ function usage {
echo "" echo ""
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present" echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment" echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
echo " -s, --no-site-packages Isolate the virtualenv from the global Python environment"
echo " -r, --recreate-db Recreate the test database (deprecated, as this is now the default)." echo " -r, --recreate-db Recreate the test database (deprecated, as this is now the default)."
echo " -n, --no-recreate-db Don't recreate the test database." echo " -n, --no-recreate-db Don't recreate the test database."
echo " -x, --stop Stop running tests after the first error or failure." echo " -x, --stop Stop running tests after the first error or failure."
@ -29,6 +30,7 @@ function process_option {
-h|--help) usage;; -h|--help) usage;;
-V|--virtual-env) always_venv=1; never_venv=0;; -V|--virtual-env) always_venv=1; never_venv=0;;
-N|--no-virtual-env) always_venv=0; never_venv=1;; -N|--no-virtual-env) always_venv=0; never_venv=1;;
-s|--no-site-packages) no_site_packages=1;;
-r|--recreate-db) recreate_db=1;; -r|--recreate-db) recreate_db=1;;
-n|--no-recreate-db) recreate_db=0;; -n|--no-recreate-db) recreate_db=0;;
-f|--force) force=1;; -f|--force) force=1;;
@ -45,6 +47,8 @@ with_venv=tools/with_venv.sh
always_venv=0 always_venv=0
never_venv=0 never_venv=0
force=0 force=0
no_site_packages=0
installvenvopts=
noseargs= noseargs=
noseopts= noseopts=
wrapper="" wrapper=""
@ -62,6 +66,10 @@ if [ $coverage -eq 1 ]; then
noseopts="$noseopts --with-coverage --cover-package=nova" noseopts="$noseopts --with-coverage --cover-package=nova"
fi fi
if [ $no_site_packages -eq 1 ]; then
installvenvopts="--no-site-packages"
fi
function run_tests { function run_tests {
# Just run the test suites in current environment # Just run the test suites in current environment
${wrapper} $NOSETESTS 2> run_tests.log ${wrapper} $NOSETESTS 2> run_tests.log
@ -123,14 +131,14 @@ then
else else
if [ $always_venv -eq 1 ]; then if [ $always_venv -eq 1 ]; then
# Automatically install the virtualenv # Automatically install the virtualenv
python tools/install_venv.py python tools/install_venv.py $installvenvopts
wrapper="${with_venv}" wrapper="${with_venv}"
else else
echo -e "No virtual environment found...create one? (Y/n) \c" echo -e "No virtual environment found...create one? (Y/n) \c"
read use_ve read use_ve
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then 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 # Install the virtualenv and run the test suite in it
python tools/install_venv.py python tools/install_venv.py $installvenvopts
wrapper=${with_venv} wrapper=${with_venv}
fi fi
fi fi