]> git.notmuchmail.org Git - notmuch/commitdiff
test: use the python interpreter in sh.config
authorDavid Bremner <david@tethera.net>
Sun, 2 Aug 2015 06:40:55 +0000 (08:40 +0200)
committerDavid Bremner <david@tethera.net>
Tue, 4 Aug 2015 07:19:18 +0000 (09:19 +0200)
The configure script chooses "python" if both python and python{2,3}
exist exists, so this could change the version of python used to run
the test suite.

The checking for ${NOTMUCH_PYTHON} in the test suite is arguably
over-engineering, since the configure step will fail if it can't find
it.

configure
test/T390-python.sh
test/test-lib.sh

index 56f550b055c5854d2588c8a36e84ddc2eb6e935c..20fbed620e14883651091a473805ca21edbf24db 100755 (executable)
--- a/configure
+++ b/configure
@@ -114,6 +114,8 @@ Other environment variables can be used to control configure itself,
        XAPIAN_CONFIG   The program to use to determine flags for
                        compiling and linking against the Xapian
                        library. [$XAPIAN_CONFIG]
        XAPIAN_CONFIG   The program to use to determine flags for
                        compiling and linking against the Xapian
                        library. [$XAPIAN_CONFIG]
+       PYTHON          Name of python command to use in
+                       configure and the test suite.
 
 Additionally, various options can be specified on the configure
 command line.
 
 Additionally, various options can be specified on the configure
 command line.
index 26d0b97663dd91fba902b35a5854d0bd68490f87..c3f24f79453208e6119dc3ea01ad20de1fe83b8b 100755 (executable)
@@ -2,6 +2,8 @@
 test_description="python bindings"
 . ./test-lib.sh
 
 test_description="python bindings"
 . ./test-lib.sh
 
+test_require_external_prereq ${NOTMUCH_PYTHON}
+
 add_email_corpus
 
 test_begin_subtest "compare thread ids"
 add_email_corpus
 
 test_begin_subtest "compare thread ids"
index 3466e9cf842ac1f439f1a2607daf70a9931f846f..db3b6aa198c7319bafb13d7b319f768169877d33 100644 (file)
@@ -621,9 +621,9 @@ test_expect_equal_json () {
     # The test suite forces LC_ALL=C, but this causes Python 3 to
     # decode stdin as ASCII.  We need to read JSON in UTF-8, so
     # override Python's stdio encoding defaults.
     # The test suite forces LC_ALL=C, but this causes Python 3 to
     # decode stdin as ASCII.  We need to read JSON in UTF-8, so
     # override Python's stdio encoding defaults.
-    output=$(echo "$1" | PYTHONIOENCODING=utf-8 python -mjson.tool \
+    output=$(echo "$1" | PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -mjson.tool \
         || echo "$1")
         || echo "$1")
-    expected=$(echo "$2" | PYTHONIOENCODING=utf-8 python -mjson.tool \
+    expected=$(echo "$2" | PYTHONIOENCODING=utf-8 $NOTMUCH_PYTHON -mjson.tool \
         || echo "$2")
     shift 2
     test_expect_equal "$output" "$expected" "$@"
         || echo "$2")
     shift 2
     test_expect_equal "$output" "$expected" "$@"
@@ -1153,14 +1153,8 @@ test_python() {
        export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib
        export PYTHONPATH=$TEST_DIRECTORY/../bindings/python
 
        export LD_LIBRARY_PATH=$TEST_DIRECTORY/../lib
        export PYTHONPATH=$TEST_DIRECTORY/../bindings/python
 
-       # Some distros (e.g. Arch Linux) ship Python 2.* as /usr/bin/python2,
-       # most others as /usr/bin/python. So first try python2, and fallback to
-       # python if python2 doesn't exist.
-       cmd=python2
-       [[ ${test_missing_external_prereq_[python2]} == t ]] && cmd=python
-
        (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \
        (echo "import sys; _orig_stdout=sys.stdout; sys.stdout=open('OUTPUT', 'w')"; cat) \
-               | $cmd -
+               | $NOTMUCH_PYTHON -
 }
 
 test_ruby() {
 }
 
 test_ruby() {
@@ -1325,5 +1319,4 @@ test_declare_external_prereq emacs
 test_declare_external_prereq ${TEST_EMACSCLIENT}
 test_declare_external_prereq gdb
 test_declare_external_prereq gpg
 test_declare_external_prereq ${TEST_EMACSCLIENT}
 test_declare_external_prereq gdb
 test_declare_external_prereq gpg
-test_declare_external_prereq python
-test_declare_external_prereq python2
+test_declare_external_prereq ${NOTMUCH_PYTHON}