#!/usr/bin/env bash function usage { echo "Usage: $0 [OPTION]..." echo "Run Tempest unit tests" echo "" 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-site-packages Isolate the virtualenv from the global Python environment" echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added." echo " -u, --update Update the virtual environment with any newer package versions" echo " -t, --serial Run testr serially" echo " -p, --pep8 Just run pep8" echo " -c, --coverage Generate coverage report" echo " -h, --help Print this usage message" echo " -d, --debug Run tests with testtools instead of testr. This allows you to use PDB" echo " -- [TESTROPTIONS] After the first '--' you can pass arbitrary arguments to testr " } function deprecation_warning { cat <&2 echo "Running flake8 without virtual env may miss OpenStack HACKING detection" >&2 fi ${wrapper} flake8 } 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 [ $update -eq 1 ]; then echo "Updating virtualenv..." virtualenv $installvenvopts $venv $venv/bin/pip install -U -r requirements.txt -r test-requirements.txt fi if [ -e ${venv} ]; then wrapper="${with_venv}" else if [ $always_venv -eq 1 ]; then # Automatically install the virtualenv virtualenv $installvenvopts $venv wrapper="${with_venv}" ${wrapper} pip install -U -r requirements.txt -r test-requirements.txt else echo -e "No virtual environment found...create one? (Y/n) \c" read use_ve 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 virtualenv $installvenvopts $venv wrapper=${with_venv} ${wrapper} pip install -U -r requirements.txt -r test-requirements.txt fi fi fi fi if [ $just_pep8 -eq 1 ]; then run_pep8 exit fi run_tests retval=$? if [ -z "$testrargs" ]; then run_pep8 fi exit $retval