Subject: Re: [perl-5.8.7] Perl regression tests fail when lib directory is present
From: Michael G Schwern <[email-masked]>
To: Andrew Ho <[email-masked]>
Cc: Scott Bolte <[email-masked]>, "Gerrit P. Haase" <[email-masked]>, [email-masked], [email-masked], [email-masked], [email-masked]
Date: Thu, 21 Jul 2005 00:14:51 -0700

On Wed, Jul 20, 2005 at 06:54:13PM -0700, Andrew Ho wrote:
> Here are the diffs between 2.42 and 2.44, the next most recent version:
> 
>     http://www.zeuscat.com/tmp/test_harness_diff.txt
>     http://www.zeuscat.com/tmp/test_harness_diff.html (colorized)
> 
> I haven't peeked through the diff yet to figure out what the cuplrit is.

DING DING DING DING!

@@ -446,9 +464,21 @@
 	s/[\\\/+]$// foreach @inc;
     }
 
-    my %dupes;
-    @inc = grep !$dupes{$_}++, @inc;
+    my %seen;
+    $seen{$_}++ foreach $self->_default_inc();
+    @inc = grep !$seen{$_}++, @inc;
+
+    return @inc;
+}
+
+
+sub _default_inc {
+    my $self = shift;
 
+    local $ENV{PERL5LIB};
+    my $perl = $self->_command;
+    my @inc =`$perl -le "print join qq[\n], \@INC"`;
+    chomp @inc;
     return @inc;
 }
 
Its gotta be something about _default_inc().  Nothing looks wrong from
here.  My only guess is that local $ENV{PERL5LIB} is ineffective.  That
would account for the alternation.

The algorithm is this.  Test::Harness has to make sure it runs tests with
the same @INC Test::Harness ran with.  To do this it could just shove all of
@INC into PERL5LIB before running the test but there's various reasons why
this is a bad idea.  So it only puts into PERL5LIB that which perl does not
already have in its @INC by default.

_default_inc() figures out what the normal Perl @INC is without any -Is or 
PERL5LIB by localizing PERL5LIB (thus temporarily clearing it) and running 
the shell command:

	perl -le "print join qq[\n], @INC"

to get perl to list its pristine @INC.  I think the localization of PERL5LIB
is failing.  This means blib/lib is still on it and it thinks its part of
the default so it strips it off.  Next time around its not there so it puts
it back on.  And so on.

Try printing out the value of $ENV{PERL5LIB} before and after the localization
inside _default_inc().  Finally, see what _default_inc returns.

sub _default_inc {
    my $self = shift;

    print STDERR "P5LIB Before: $ENV{PERL5LIB}\n";
    local $ENV{PERL5LIB};
    print STDERR "P5LIB After:  $ENV{PERL5LIB}\n";

    my $perl = $self->_command;
    my @inc =`$perl -le "print join qq[\\n], \@INC"`;
    chomp @inc;

    print STDERR "Default @INC: @inc\n";
    return @inc;
}

And then try changing "local $ENV{PERL5LIB}" to "local $ENV{PERL5LIB} = ''".

-- 
Michael G Schwern     [email-masked]     http://www.pobox.com/~schwern
Reality is that which, when you stop believing in it, doesn't go away.
	-- Phillip K. Dick

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/