[gnumeric] Tests: add basic test for introspection.



commit a9dc96be5741d9bff8a05763e337cfc1334e1b57
Author: Morten Welinder <terra gnome org>
Date:   Wed Apr 11 13:10:50 2018 -0400

    Tests: add basic test for introspection.

 NEWS                              |    1 +
 test/GnumericTest.pm              |   17 +++++++++++++++--
 test/Makefile.am                  |   20 ++++++++++++++++++--
 test/t3000-introspection-basic.pl |   13 +++++++++++++
 test/t3000-introspection-basic.py |    8 ++++++++
 5 files changed, 55 insertions(+), 4 deletions(-)
---
diff --git a/NEWS b/NEWS
index 411a310..4c15577 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Morten:
        * Add GUI for comparing sheets.
        * Introspection fixes.
        * Clean up workbook view construction.
+       * Test suite improvements.
 
 --------------------------------------------------------------------------
 Gnumeric 1.12.39
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index df5a0d9..18e0f6a 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -13,15 +13,18 @@ $| = 1;
                            test_csv_format_guessing
                           test_ssindex sstest test_command message subtest
                            test_tool
+                           setup_python_environment
                           $ssconvert $sstest $ssdiff $ssgrep $gnumeric
                            $topsrc $top_builddir
-                          $subtests $samples corpus $PERL);
+                          $subtests $samples corpus $PERL $PYTHON);
 @GnumericTest::EXPORT_OK = qw(junkfile);
 
-use vars qw($topsrc $top_builddir $samples $default_subtests $default_corpus $PERL $verbose);
+use vars qw($topsrc $top_builddir $samples $default_subtests $default_corpus $PERL $PYTHON $verbose);
 use vars qw($ssconvert $ssindex $sstest $ssdiff $ssgrep $gnumeric);
 use vars qw($normalize_gnumeric);
 
+$PYTHON = undef;
+
 $PERL = $Config{'perlpath'};
 $PERL .= $Config{'_exe'} if $^O ne 'VMS' && $PERL !~ m/$Config{'_exe'}$/i;
 
@@ -881,6 +884,16 @@ sub has_linear_solver {
 
 # -----------------------------------------------------------------------------
 
+sub setup_python_environment {
+    $PYTHON = '/usr/bin/python';
+    &report_skip ("Missing $PYTHON") unless -x $PYTHON;
+
+    # Make sure we load introspection preferentially from build directory
+    my $v = 'GI_TYPELIB_PATH';
+    my $dir = "$top_builddir/src";
+    $ENV{$v} = ($ENV{$v} || '') eq '' ? $dir : $dir . ':' . $ENV{$v};
+}
+
 sub quotearg {
     return join (' ', map { &quotearg1 ($_) } @_);
 }
diff --git a/test/Makefile.am b/test/Makefile.am
index 965ce88..5e046b7 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -8,6 +8,8 @@
 #
 # 2xxx: Internal sstest
 #
+# 3xxx: Introspection tests
+#
 # 5xxx: Importers
 # 5800:   csv
 # 59xx:   Minor formats with import-db
@@ -177,10 +179,24 @@ TESTS =   t1000-statfuns.pl                       \
 
 SUPPS = common.supp gui.supp t8003-valgrind-pdf.supp
 
+INTROSPECTION_TSTS = \
+       t3000-introspection-basic.pl
+INTROSPECTION_SUPPS = \
+       $(INTROSPECTION_TSTS:.pl=.py)
+if HAVE_INTROSPECTION
+  TESTS += $(INTROSPECTION_TSTS)
+  SUPPS += $(INTROSPECTION_SUPPS)
+endif
+
+
 import-db:
        for t in $(srcdir)/t59[0-9][0-9]-*.pl; do echo "*** $$t ***"; $(PERL) $$t create-db; done
 
+EXTRA_DIST = GnumericTest.pm \
+       $(SUPPS) $(TESTS) \
+       $(INTROSPECTION_SUPPS) $(INTROSPECTION_TSTS) \
+       normalize-gnumeric \
+       ods-ext-schema.patch 
 
-EXTRA_DIST = GnumericTest.pm $(SUPPS) normalize-gnumeric ods-ext-schema.patch $(TESTS)
-.PHONY: import-db $(TESTS)
+.PHONY: import-db
 .NOTPARALLEL:
diff --git a/test/t3000-introspection-basic.pl b/test/t3000-introspection-basic.pl
new file mode 100755
index 0000000..918f251
--- /dev/null
+++ b/test/t3000-introspection-basic.pl
@@ -0,0 +1,13 @@
+#!/usr/bin/perl -w
+# -----------------------------------------------------------------------------
+
+use strict;
+use lib ($0 =~ m|^(.*/)| ? $1 : ".");
+use GnumericTest;
+
+&setup_python_environment ();
+
+my $python_script = $0;
+$python_script =~ s/\.pl$/.py/;
+&test_command ($PYTHON . ' ' . &GnumericTest::quotearg ($python_script),
+              sub { /^[-+.0-9]+$/ && abs ($_ - -0.253347103136) < 1e-10 });
diff --git a/test/t3000-introspection-basic.py b/test/t3000-introspection-basic.py
new file mode 100755
index 0000000..c3ee058
--- /dev/null
+++ b/test/t3000-introspection-basic.py
@@ -0,0 +1,8 @@
+#!/usr/bin/python
+# -----------------------------------------------------------------------------
+
+import gi
+gi.require_version('Gnm', '1.12') 
+from gi.repository import Gnm
+
+print Gnm.qnorm(0.4,0,1,1,0)


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