[gnumeric] Tests: skip linear solver tests if no linear solver binary is found



commit 0db787eb708cd34be3ee89da26aa20e51e9cf4c3
Author: Morten Welinder <terra gnome org>
Date:   Sun Nov 26 13:47:24 2017 -0500

    Tests: skip linear solver tests if no linear solver binary is found

 test/GnumericTest.pm       |   13 ++++++++++++-
 test/t7100-solver-blend.pl |    3 +++
 test/t7101-solver-afiro.pl |    3 +++
 3 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index b147e95..69a38b6 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -123,7 +123,7 @@ sub dump_indented {
 }
 
 sub find_program {
-    my ($p) = @_;
+    my ($p, $nofail) = @_;
 
     if ($p =~ m{/}) {
        return $p if -x $p;
@@ -136,6 +136,8 @@ sub find_program {
        }
     }
 
+    return undef if $nofail;
+
     &report_skip ("$p is missing");
 }
 
@@ -868,6 +870,15 @@ sub test_tool {
     }
 }
 
+# -----------------------------------------------------------------------------
+
+sub has_linear_solver {
+    return (defined (&find_program ('lp_solve', 1)) ||
+           defined (&find_program ('glpsol', 1)));
+}
+
+# -----------------------------------------------------------------------------
+
 sub quotearg {
     return join (' ', map { &quotearg1 ($_) } @_);
 }
diff --git a/test/t7100-solver-blend.pl b/test/t7100-solver-blend.pl
index a4740fd..5b78ab3 100755
--- a/test/t7100-solver-blend.pl
+++ b/test/t7100-solver-blend.pl
@@ -5,6 +5,9 @@ use strict;
 use lib ($0 =~ m|^(.*/)| ? $1 : ".");
 use GnumericTest;
 
+&GnumericTest::report_skip ("No linear solver found")
+    unless &GnumericTest::has_linear_solver ();
+
 my $file = "blend.mps";
 my $answer = -30.8121498458281;
 # lp_solve:  -30.81221619004;
diff --git a/test/t7101-solver-afiro.pl b/test/t7101-solver-afiro.pl
index ced8b4e..734e8e0 100755
--- a/test/t7101-solver-afiro.pl
+++ b/test/t7101-solver-afiro.pl
@@ -5,6 +5,9 @@ use strict;
 use lib ($0 =~ m|^(.*/)| ? $1 : ".");
 use GnumericTest;
 
+&GnumericTest::report_skip ("No linear solver found")
+    unless &GnumericTest::has_linear_solver ();
+
 my $file = "afiro.mps";
 my $answer = -464.753216;
 # lp_solve:  -464.753216;


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