4
echo "Usage: $0 [OPTION]..."
5
echo "Run Keystone's test suite(s)"
7
echo " -V, --virtual-env Always use virtualenv. Install automatically if not present"
8
echo " -N, --no-virtual-env Don't use virtualenv. Run tests in local environment"
9
echo " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
10
echo " --unittests-only Run unit tests only, exclude functional tests."
11
echo " -p, --pep8 Just run pep8"
12
echo " -l, --pylint Just run pylint"
13
echo " -h, --help Print this usage message"
15
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
16
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
17
echo " prefer to run tests NOT in a virtual environment, simply pass the -N option."
21
function process_option {
24
-V|--virtual-env) let always_venv=1; let never_venv=0;;
25
-N|--no-virtual-env) let always_venv=0; let never_venv=1;;
26
-p|--pep8) let just_pep8=1; let never_venv=1;;
27
-l|--pylint) let just_pylint=1; let never_venv=0;;
28
-f|--force) let force=1;;
29
--unittests-only) noseargs="$noseargs --exclude-dir=keystone/tests/functional --exclude-dir=keystone/tests/system";;
30
*) noseargs="$noseargs $1"
35
with_venv=tools/with_venv.sh
49
# Just run the test suites in current environment
54
echo "Running pep8 ..."
55
PEP8_EXCLUDE="vcsversion.py"
56
PEP8_OPTIONS="--exclude=$PEP8_EXCLUDE --repeat --show-pep8 --show-source"
57
PEP8_INCLUDE="bin/k* keystone examples tools setup.py run_tests.py"
58
pep8 $PEP8_OPTIONS $PEP8_INCLUDE
62
echo "Running pylint ..."
63
PYLINT_OPTIONS="--rcfile=.pylintrc --output-format=parseable"
64
PYLINT_INCLUDE="keystone"
65
echo "Pylint messages count: "
66
pylint $PYLINT_OPTIONS $PYLINT_INCLUDE | grep 'keystone/' | wc -l
67
echo "Run 'pylint $PYLINT_OPTIONS $PYLINT_INCLUDE' for a full report."
71
NOSETESTS="python run_tests.py $noseargs"
73
if [ $never_venv -eq 0 ]
75
# Remove the virtual environment if --force used
76
if [ $force -eq 1 ]; then
77
echo "Cleaning virtualenv..."
80
if [ -e ${venv} ]; then
81
wrapper="${with_venv}"
83
if [ $always_venv -eq 1 ]; then
84
# Automatically install the virtualenv
85
python tools/install_venv.py
86
wrapper="${with_venv}"
88
echo -e "No virtual environment found...create one? (Y/n) \c"
90
if [ "x$use_ve" = "xY" -o "x$use_ve" = "x" -o "x$use_ve" = "xy" ]; then
91
# Install the virtualenv and run the test suite in it
92
python tools/install_venv.py
99
if [ $just_pep8 -eq 1 ]; then
104
if [ $just_pylint -eq 1 ]; then
111
#if [ -z "$noseargs" ]; then