From 644a3e437641699c19be4345feb9504b9d2a4603 Mon Sep 17 00:00:00 2001 From: Thomas Goirand Date: Sun, 3 Jun 2018 11:13:17 +0200 Subject: [PATCH] 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 --- tools/oslo_debug_helper | 8 +++++--- tools/oslo_run_cross_tests | 10 +++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/tools/oslo_debug_helper b/tools/oslo_debug_helper index 30d934f..0de7efd 100755 --- a/tools/oslo_debug_helper +++ b/tools/oslo_debug_helper @@ -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 diff --git a/tools/oslo_run_cross_tests b/tools/oslo_run_cross_tests index 1412b6f..a657ab9 100755 --- a/tools/oslo_run_cross_tests +++ b/tools/oslo_run_cross_tests @@ -9,6 +9,8 @@ # Fail the build if any command fails set -e +PYTHON=${PYTHON:-python} + function usage { cat - <