Invoke correct python version in shell scripts
The oslotest shell scripts were using /usr/bin/python by default, and did take into account the $PYTHON variable, so one could choose to use Python 3 instead of Python 2. This patch looks if a $PYTHON variable exists. If not, then it sets it to "python" by default, otherwise, it uses whatever exists, so it is now possible to do PYTHON=python3 oslo_debug_helper for starting tests. Change-Id: I6df0ac0d84fd964251a1af9e27dadb954a2ad691
This commit is contained in:
parent
ed19115476
commit
644a3e4376
@ -10,6 +10,8 @@
|
||||
# relative to the project directory. If no value is passed, it is assumed
|
||||
# to be packagename/tests.
|
||||
|
||||
PYTHON=${PYTHON:-python}
|
||||
|
||||
TMP_DIR=`mktemp -d debug-$$-XXX` || exit 1
|
||||
trap "rm -rf $TMP_DIR" EXIT
|
||||
|
||||
@ -17,7 +19,7 @@ ALL_TESTS=$TMP_DIR/all_tests
|
||||
TESTS_TO_RUN=$TMP_DIR/tests_to_run
|
||||
|
||||
# Default to packagename/tests, i.e., keystone/tests
|
||||
PACKAGENAME=$(python setup.py --name)
|
||||
PACKAGENAME=$(${PYTHON} setup.py --name)
|
||||
TEST_DIR=./$PACKAGENAME/tests
|
||||
|
||||
# If a specific path is passed, use that one
|
||||
@ -27,7 +29,7 @@ while getopts ":t:" opt; do
|
||||
esac
|
||||
done
|
||||
|
||||
python -m testtools.run discover -t ./ $TEST_DIR --list > $ALL_TESTS
|
||||
${PYTHON} -m testtools.run discover -t ./ $TEST_DIR --list > $ALL_TESTS
|
||||
|
||||
# getopts friendly way of determining if a positional arg has been passed
|
||||
ARG1=${@:$OPTIND:1}
|
||||
@ -37,4 +39,4 @@ else
|
||||
mv $ALL_TESTS $TESTS_TO_RUN
|
||||
fi
|
||||
|
||||
python -m testtools.run discover --load-list $TESTS_TO_RUN
|
||||
${PYTHON} -m testtools.run discover --load-list $TESTS_TO_RUN
|
||||
|
@ -9,6 +9,8 @@
|
||||
# Fail the build if any command fails
|
||||
set -e
|
||||
|
||||
PYTHON=${PYTHON:-python}
|
||||
|
||||
function usage {
|
||||
cat - <<EOF
|
||||
ERROR: Missing argument(s)
|
||||
@ -46,13 +48,13 @@ fi
|
||||
|
||||
tox_envbin=$project_dir/.tox/$venv/bin
|
||||
|
||||
our_name=$(python setup.py --name)
|
||||
our_name=$(${PYTHON} setup.py --name)
|
||||
|
||||
# Build the egg-info, including the source file list,
|
||||
# so we install all of the files, even if the package
|
||||
# list or name has changed.
|
||||
rm -rf $(python setup.py --name).egg-info
|
||||
python setup.py egg_info
|
||||
rm -rf $(${PYTHON} setup.py --name).egg-info
|
||||
${PYTHON} setup.py egg_info
|
||||
|
||||
# Replace the pip-installed package with the version in our source
|
||||
# tree. Look to see if we are already installed before trying to
|
||||
@ -92,8 +94,6 @@ if [ -f /usr/local/jenkins/slave_scripts/subunit2html.py -a -d ".testrepository"
|
||||
gzip -9 ./subunit_log.txt
|
||||
gzip -9 ./testr_results.html
|
||||
|
||||
export PYTHON=.tox/$venv/bin/python
|
||||
set -e
|
||||
rancount=$(.tox/$venv/bin/testr last | sed -ne 's/Ran \([0-9]\+\).*tests in.*/\1/p')
|
||||
if [ "$rancount" -eq "0" ] ; then
|
||||
echo
|
||||
|
Loading…
Reference in New Issue
Block a user