Files
98953b79099d5c64050bace9aa52fcbfa0e21325
nova /run_tests.sh

233 lines
6.9 KiB
Bash
Raw Normal View History

echo "Usage: 0ドル [OPTION]..."
echo "Run Nova's test suite(s)"
echo ""
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 " -f, --force Force a clean re-build of the virtual environment. Useful when dependencies have been added."
echo " -P, --no-pep8 Don't run static code checks"
echo " -c, --coverage Generate coverage report"
echo " --hide-elapsed Don't print the elapsed time for each test along with slow test list"
echo " --virtual-env-path <path> Location of the virtualenv directory"
echo " Default: \$(pwd)"
echo " --virtual-env-name <name> Name of the virtualenv directory"
echo " Default: .venv"
echo " --tools-path <dir> Location of the tools directory"
echo " Default: \$(pwd)"
echo " Default: 0"
echo "Note: with no options specified, the script will try to run the tests in a virtual environment,"
echo " If no virtualenv is found, the script will ask if you would like to create one. If you "
echo " prefer to run tests NOT in a virtual environment, simply pass the -N option."
exit
}
i=1
while [ $i -le $# ]; do
case "${!i}" in
-h|--help) usage;;
-V|--virtual-env) always_venv=1; never_venv=0;;
-N|--no-virtual-env) always_venv=0; never_venv=1;;
-s|--no-site-packages) no_site_packages=1;;
-f|--force) force=1;;
-P|--no-pep8) no_pep8=1;;
-c|--coverage) coverage=1;;
(( i++ ))
venv_path=${!i}
;;
--virtual-env-name)
(( i++ ))
venv_dir=${!i}
;;
--tools-path)
(( i++ ))
tools_path=${!i}
;;
(( i++ ))
concurrency=${!i}
;;
*) testrargs="$testrargs${!i}"
(( i++ ))
done
venv_path=${venv_path:-$(pwd)}
venv_dir=${venv_name:-.venv}
never_venv=0
installvenvopts=
testropts=
coverage=0
2010年12月28日 01:40:24 -08:00
LANGUAGE=en_US:en
LC_ALL=C
# Make our paths available to other scripts we call
export venv_path
export venv_dir
export venv_name
export tools_dir
export venv=${venv_path}/${venv_dir}
installvenvopts="--no-site-packages"
fi
${wrapper} find . -type f -name "*.pyc" -delete
if [ "$testropts" = "" ] && [ "$testrargs" = "" ]; then
# Default to running all tests if specific test is not
# provided.
testrargs="discover ./nova/tests"
fi
${wrapper} python -m testtools.run $testropts $testrargs
# Short circuit because all of the testr and coverage stuff
# below does not make sense when running testtools.run for
# debugging purposes.
return $?
fi
else
2011年02月23日 08:46:11 -08:00
fi
set +e
then
${wrapper} python setup.py egg_info
fi
then
# subunit-2to1 is present, testr subunit stream should be in version 2
# format. Convert to version one before colorizing.
bash -c "${wrapper}$TESTRTESTS | ${wrapper} subunit-2to1 | ${wrapper} tools/colorizer.py"
else
bash -c "${wrapper}$TESTRTESTS | ${wrapper} tools/colorizer.py"
fi
set -e
copy_subunit_log
echo "Generating coverage report in covhtml/"
# Don't compute coverage for common code, which is tested elsewhere
${wrapper} coverage combine
${wrapper} coverage html --include='nova/*' --omit='nova/openstack/common/*' -d covhtml -i
fi
2011年02月23日 08:46:11 -08:00
return $RESULT
LOGNAME=`cat .testrepository/next-stream`
LOGNAME=$(($LOGNAME - 1))
LOGNAME=".testrepository/${LOGNAME}"
cp $LOGNAME subunit.log
}
echo "**WARNING**:"
echo "Running flake8 without virtual env may miss OpenStack HACKING detection"
fi
then
# Remove the virtual environment if --force used
if [ $force -eq 1 ]; then
echo "Cleaning virtualenv..."
rm -rf ${venv}
fi
echo "Updating virtualenv..."
python tools/install_venv.py $installvenvopts
fi
wrapper="${with_venv}"
# Automatically install the virtualenv
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
wrapper=${with_venv}
fi
# Delete old coverage data from previous runs
if [ $coverage -eq 1 ]; then
${wrapper} coverage erase
fi
2011年06月07日 16:08:25 -04:00
if [ $just_pep8 -eq 1 ]; then
run_pep8
exit
fi
# NOTE(sirp): we only want to run pep8 when we're running the full-test suite,
# not when we're running tests individually. To handle this, we need to
# arguments (testrargs).
if [ -z "$testrargs" ]; then
run_pep8
fi
fi