Re: [patch] improve versatility and reliability of some test scripts



On 8/21/19 4:16 PM, Morten Welinder wrote:

This breaks "make distcheck" for me.

My bad. Sorry to cause trouble, and thanks for your patience.

Here is a more conservative approach to alleviating the problem.
It appears that $topsrc and $top_builddir are being used in
inconsistent ways.  I don't see any way to impose a consistent
meaning on them in a way that would fix old bugs without
introducing new bugs.  So instead I defined a new variable
$abs_builddir and used it in places where it was easy to
figure out what meaning was needed.

There is no reason to expect that all test scripts can now
be invoked from outside the test directory, but /some/ can.

Legacy situations such as "make" and "make distcheck" should
be unaffected.

commit 5b06783deec17f4961a59f91d37f28bad0a7bd46
Author: John Denker <jsd av8n com>
Date:   Thu Aug 22 00:33:36 2019 -0700

    allow some test scripts to be invoked via nontrivial filespecs, e.g
      cd /some/where/gnumeric
      ./test/t3001*.pl
    without having to cd to the test directory

diff --git a/test/GnumericTest.pm b/test/GnumericTest.pm
index 0de6467c4..40a2e0691 100644
--- a/test/GnumericTest.pm
+++ b/test/GnumericTest.pm
@@ -1,7 +1,7 @@
 package GnumericTest;
 use strict;
 use Exporter;
-use File::Basename qw(fileparse);
+use File::Basename qw(fileparse dirname);
 use Config;
 use XML::Parser;
 
@@ -20,7 +20,7 @@ $| = 1;
                           $subtests $samples corpus $PERL $PYTHON);
 @GnumericTest::EXPORT_OK = qw(junkfile);
 
-use vars qw($topsrc $top_builddir $samples $default_subtests $default_corpus $PERL $PYTHON $verbose);
+use vars qw($topsrc $top_builddir $abs_builddir $samples $default_subtests $default_corpus $PERL $PYTHON 
$verbose);
 use vars qw($ssconvert $ssindex $sstest $ssdiff $ssgrep $gnumeric);
 use vars qw($normalize_gnumeric);
 
@@ -39,14 +39,17 @@ if ($0 eq '-e') {
 }
 
 $top_builddir = "..";
-$samples = "$topsrc/samples"; $samples =~ s{^\./+}{};
-$ssconvert = "$top_builddir/src/ssconvert";
-$ssindex = "$top_builddir/src/ssindex";
-$sstest = "$top_builddir/src/sstest";
-$ssdiff = "$top_builddir/src/ssdiff";
-$ssgrep = "$top_builddir/src/ssgrep";
-$gnumeric = "$top_builddir/src/gnumeric";
-$normalize_gnumeric = "$PERL $topsrc/test/normalize-gnumeric";
+# make_absolute($0) is probably /some/where/gnumeric/test/script.pl
+$abs_builddir = dirname(dirname(make_absolute($0)));   # /some/where/gnumeric
+
+$samples = "$abs_builddir/samples";
+$ssconvert = "$abs_builddir/src/ssconvert";
+$ssindex = "$abs_builddir/src/ssindex";
+$sstest = "$abs_builddir/src/sstest";
+$ssdiff = "$abs_builddir/src/ssdiff";
+$ssgrep = "$abs_builddir/src/ssgrep";
+$gnumeric = "$abs_builddir/src/gnumeric";
+$normalize_gnumeric = "$PERL $abs_builddir/test/normalize-gnumeric";
 $verbose = 0;
 $default_subtests = '*';
 my $subtests = undef;
@@ -680,7 +683,7 @@ sub test_roundtrip {
        die "Failed to produce $file_filtered\n" unless -r $file_filtered;
        &junkfile ($file_filtered) unless $keep;
     }
-    
+
     my $tmp1 = "$tmp.$newext";
     unlink $tmp1;
     &junkfile ($tmp1) unless $keep;
@@ -911,23 +914,23 @@ sub make_absolute {
 # -----------------------------------------------------------------------------
 
 sub setup_python_environment {
-    $PYTHON = `grep '^#define PYTHON_INTERPRETER ' $top_builddir/gnumeric-config.h 2>&1`;
+    $PYTHON = `grep '^#define PYTHON_INTERPRETER ' $abs_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';
-    my $dir = "$top_builddir/src";
+    my $dir = "$abs_builddir/src";
     $ENV{$v} = ($ENV{$v} || '') eq '' ? $dir : $dir . ':' . $ENV{$v};
 
     # Ditto for shared libraries
     $v = 'LD_LIBRARY_PATH';
-    $dir = "$top_builddir/src/.libs";
+    $dir = "$abs_builddir/src/.libs";
     $ENV{$v} = ($ENV{$v} || '') eq '' ? $dir : $dir . ':' . $ENV{$v};
 
-    $ENV{'PYTHONPATH'} = "$topsrc/introspection";
-    
+    $ENV{'PYTHONPATH'} = "$abs_builddir/introspection";
+
     # Don't litter
     $ENV{'PYTHONDONTWRITEBYTECODE'} = 1;
 


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