Subject: bug#8847: [PATCH 4/8] tests: honour $PYTHON override

From: Stefano Lattarini <[email-masked]>
Date: Mon, 19 Nov 2012 23:12:19 +0100

* t/ax/am-test-lib.sh (require_tool): Here.
* t/python-too-old.sh: And here.
* t/python-vars.sh: And here.
* t/python-virtualenv.sh: And here.  Also add some sanity
checks while at it.

Signed-off-by: Stefano Lattarini <[email-masked]>
---
 t/ax/am-test-lib.sh    | 5 +++--
 t/python-too-old.sh    | 3 ++-
 t/python-vars.sh       | 2 --
 t/python-virtualenv.sh | 9 ++++++++-
 4 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/t/ax/am-test-lib.sh b/t/ax/am-test-lib.sh
index e69a904..85fb7c4 100644
--- a/t/ax/am-test-lib.sh
+++ b/t/ax/am-test-lib.sh
@@ -662,8 +662,9 @@ require_tool ()
       ;;
     python)
       # Python doesn't support --version, it has -V
-      echo "$me: running python -V"
-      python -V || skip_all_ "python interpreter not available"
+      PYTHON=${PYTHON-python}
+      echo "$me: running $PYTHON -V"
+      $PYTHON -V || skip_all_ "python interpreter not available"
       ;;
     ro-dir)
       # Skip this test case if read-only directories aren't supported
diff --git a/t/python-too-old.sh b/t/python-too-old.sh
index e4185fc..b479c9e 100755
--- a/t/python-too-old.sh
+++ b/t/python-too-old.sh
@@ -34,6 +34,7 @@ py_too_old ()
   grep '[Pp]ython interpreter is too old' stderr
 }
 
+saved_PYTHON=$PYTHON; export saved_PYTHON
 PYTHON=; unset PYTHON
 
 cat > configure.ac <<END
@@ -50,7 +51,7 @@ py_too_old python
 mkdir bin
 cat > bin/my-python << 'END'
 #! /bin/sh
-exec python ${1+"$@"}
+exec $saved_PYTHON ${1+"$@"}
 END
 chmod a+x bin/my-python
 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
diff --git a/t/python-vars.sh b/t/python-vars.sh
index 5bac280..0c2c08b 100755
--- a/t/python-vars.sh
+++ b/t/python-vars.sh
@@ -23,8 +23,6 @@ required=python
 # In case the user's config.site defines pythondir or pyexecdir.
 CONFIG_SITE=/dev/null; export CONFIG_SITE
 
-PYTHON=python
-
 # Update the definition below if the documentation changes.
 # Note that the value of the 'pythondir' and 'pyexecdir' variables can
 # vary among different python installations, so we need more relaxed
diff --git a/t/python-virtualenv.sh b/t/python-virtualenv.sh
index f1e0494..23a9edc 100755
--- a/t/python-virtualenv.sh
+++ b/t/python-virtualenv.sh
@@ -23,8 +23,10 @@ required='cc python virtualenv'
 # In case the user's config.site defines pythondir or pyexecdir.
 CONFIG_SITE=/dev/null; export CONFIG_SITE
 
+py_version_pre=$($PYTHON -V)
+
 # Skip the test if a proper virtualenv cannot be created.
-virtualenv --verbose virtenv && test -f virtenv/bin/activate \
+virtualenv -p"$PYTHON" --verbose virtenv && test -f virtenv/bin/activate \
   || skip_ "couldn't create python virtual environment"
 
 # Activate the virtualenv.
@@ -34,6 +36,11 @@ if test -z "$VIRTUAL_ENV"; then
   framework_failure_ "can't activate python virtual environment"
 fi
 
+py_version_post=$(python -V)
+
+# Sanity check.
+test "$py_version_pre" = "$py_version_post"
+
 cwd=$(pwd) || fatal_ "getting current working directory"
 py_version=$(python -c 'import sys; print("%u.%u" % tuple(sys.version_info[:2]))')
 py_site=$VIRTUAL_ENV/lib/python$py_version/site-packages
-- 
1.8.0.209.gf3828dc