[gnumeric] Introspection: only run tests when "gi" python module is available.



commit 4d120f18cdaefa384c8f4a3f8bab15afd6299039
Author: Morten Welinder <terra gnome org>
Date:   Sat Apr 14 21:31:57 2018 -0400

    Introspection: only run tests when "gi" python module is available.
    
    Also ensure that tests get run with the requested Python interpreter.

 configure.ac         |   21 ++++++++++++++++++++-
 test/GnumericTest.pm |    6 ++++--
 test/Makefile.am     |    4 ++++
 3 files changed, 28 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b33afd6..eef86fe 100644
--- a/configure.ac
+++ b/configure.ac
@@ -855,7 +855,7 @@ If you want to specify a path to your Python executable, use:
        $srcdir/configure PYTHON=/path/to/your/python ...]);;
 esac
 if test "x$with_python" != xno; then
-    AC_CHECK_PROGS(PYTHON, python python2 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0)
+    AC_PATH_PROGS(PYTHON, python python2 python2.7)
     if test "x$PYTHON" = x; then
        python_msg="could not find python"
     fi
@@ -863,6 +863,24 @@ else
     python_msg="Disabled by request"
 fi
 
+# A bit of a mess.  We really ought to separate the Python interpreter
+# and the Python plugin
+have_python=no
+have_python_gi=no
+if test "x$PYTHON" != x; then
+    AC_DEFINE_UNQUOTED(PYTHON_INTERPRETER, ["$PYTHON"],
+                      [The Python interpreter to use])
+    have_python=yes
+
+    AC_MSG_CHECKING([for python module gi])
+    if $PYTHON -c 'import gi' 2>/dev/null; then
+        have_python_gi=yes
+    fi
+    AC_MSG_RESULT($have_python_gi)
+fi
+AM_CONDITIONAL(HAVE_PYTHON_GI, test "x$have_python_gi" = "xyes")
+
+
 if test "x$python_msg" = xyes; then
     BIG_CHECKING([for python = 2.x])
     [PY_VERSION=`$PYTHON -c 'import sys ; sys.stdout.write(sys.version[0:3])'`
@@ -1099,6 +1117,7 @@ AC_ARG_WITH([typelib-dir],
 )
 AC_SUBST(TYPELIBDIR)
 
+
 dnl **************************************************
 dnl * Config defaults
 dnl **************************************************
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index 5e5a39f..3cd3d8c 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -886,8 +886,10 @@ sub has_linear_solver {
 # -----------------------------------------------------------------------------
 
 sub setup_python_environment {
-    $PYTHON = '/usr/bin/python';
-    &report_skip ("Missing $PYTHON") unless -x $PYTHON;
+    $PYTHON = `grep '^#define PYTHON_INTERPRETER ' $top_builddir/gnumeric-config.h 2>&1`;
+    chomp $PYTHON;
+    $PYTHON =~ s/^[^"]*"(.*)"\s*$/$1/;
+    &report_skip ("Missing python interpreter") unless -x $PYTHON;
 
     # Make sure we load introspection preferentially from build directory
     my $v = 'GI_TYPELIB_PATH';
diff --git a/test/Makefile.am b/test/Makefile.am
index b45dc19..0db2824 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -187,10 +187,14 @@ INTROSPECTION_TSTS = \
 
 INTROSPECTION_SUPPS = \
        $(INTROSPECTION_TSTS:.pl=.py)
+
+# Activate only when we have both introspection and the "gi" module
 if HAVE_INTROSPECTION
+if HAVE_PYTHON_GI
   TESTS += $(INTROSPECTION_TSTS)
   SUPPS += $(INTROSPECTION_SUPPS)
 endif
+endif
 
 
 import-db:


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]