Skip Menu |

This queue is for tickets about the Test-Harness CPAN distribution.

Report information
The Basics
Id: 5649
Status: resolved
Priority: 0/
Queue: Test-Harness

People
Owner: Nobody in particular
Requestors: dwheeler [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Test::Harness Improperly Adds Old Architecture-Specific Directories to @INC
This is the test script: #!/usr/bin/perl -w use strict; use Test::More tests => 1; diag $_ for @INC; ok 1; Here's what happens when I just run it with Perl: sahlins% perl try 1..1 # /usr/local/lib/perl5/5.8.2/i386-freebsd # /usr/local/lib/perl5/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.0 # /usr/local/lib/perl5/site_perl/5.6.1 # /usr/local/lib/perl5/site_perl/5.005 # /usr/local/lib/perl5/site_perl # . ok 1 All is well in the world. However, here's what happens when I run it through Test::Harness: sahlins% prove try try...# /usr/local/lib/perl5/5.8.2/i386-freebsd # /usr/local/lib/perl5/5.8.2/i386-freebsd # /usr/local/lib/perl5/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.0 # /usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd # /usr/local/lib/perl5/site_perl/5.6.1 # /usr/local/lib/perl5/site_perl/5.005/i386-freebsd # /usr/local/lib/perl5/site_perl/5.005 # /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.0 # /usr/local/lib/perl5/site_perl/5.6.1 # /usr/local/lib/perl5/site_perl/5.005 # /usr/local/lib/perl5/site_perl # . # /usr/local/lib/perl5/5.8.2/i386-freebsd # /usr/local/lib/perl5/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.2 # /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd # /usr/local/lib/perl5/site_perl/5.8.0 # /usr/local/lib/perl5/site_perl/5.6.1 # /usr/local/lib/perl5/site_perl/5.005 # /usr/local/lib/perl5/site_perl # . try...ok All tests successful. Files=1, Tests=1, 0 wallclock secs ( 0.02 cusr + 0.01 csys = 0.03 CPU) Yow! Those architecture-specific directories for older versions of Perl should _not_ be in @INC! I ran into this problem while testing DBI-1.42rc1. It does some tests using BerkeleyDB, which is a compiled module. I didn't have it installed for Perl 5.8, but I did for Perl 5.6.1. So when I ran the tests, Perl was finding it in /usr/local/lib/perl5/site_perl/5.6.1/i386-freebsd, and of course, because it's not binary compatabile, it died horribly! I'm not sure how all of those extra directories are getting inserted into @INC by Test::Harness, but I think that's gotta stop. sahlins% perl -MTest::Harness -le 'print Test::Harness->VERSION' 2.40 sahlins% perl -V Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration: Platform: osname=freebsd, osvers=4.8-stable, archname=i386-freebsd uname='freebsd sahlins.kineticode.com 4.8-stable freebsd 4.8-stable #0: thu may 29 15:09:07 edt 2003 cap@pb14.pair.com:usrsrcsyscompilepaird i386 ' config_args='-des -Dprefix=/usr/local -Dperladmin=david@kineticode.com -Dcf_email=david@kineticode.com' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include', optimize='-O', cppflags='-DHAS_FPSETMASK -DHAS_FLOATINGPOINT_H -fno-strict-aliasing -I/usr/local/include' ccversion='', gccversion='2.95.4 20020320 [FreeBSD]', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags ='-Wl,-E -L/usr/local/lib' libpth=/usr/lib /usr/local/lib libs=-lgdbm -ldb -lm -lcrypt -lutil -lc perllibs=-lm -lcrypt -lutil -lc libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags='-DPIC -fPIC', lddlflags='-shared -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: USE_LARGE_FILES Built under freebsd Compiled at Nov 5 2003 17:06:51 @INC: /usr/local/lib/perl5/5.8.2/i386-freebsd /usr/local/lib/perl5/5.8.2 /usr/local/lib/perl5/site_perl/5.8.2/i386-freebsd /usr/local/lib/perl5/site_perl/5.8.2 /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl .
Andy and I talked about this a bit. Test::Harness shoves a copy of @INC onto PERL5LIB. This is so that -Iblib/lib and -Iblib/arch (and anything else not in the default @INC) get propegated to the test processes. T::H doesn't really know what's been added to @INC so it just throws the whole thing on there. This usually doesn't cause any harm because PERL5LIB has a complete, duplicate @INC. But if you have $Config{inc_version_list} set, as apparently Fedora Core does, Perl desperately tries to find versioned directories below everything in PERL5LIB. Now you get the real wackiness. So what needs to happen is T::H has to only put the things into PERL5LIB which would not already be there. To do this it needs to find out what the default @INC is without and -I's or PERL5LIB. Then it removes any duplicates in its own @INC. The result is stuck onto PERL5LIB. Working on a patch.
PS This is a really old bug. Back somewhere before I took over T::H. The thing is $Confi{inc_version_list} is new so it never mattered until recently. Here's a patch, not fully tested. --- lib/Test/Harness/Straps.pm 11 Sep 2004 04:58:17 -0000 1.37 +++ lib/Test/Harness/Straps.pm 25 Nov 2004 05:44:50 -0000 @@ -450,12 +450,24 @@ } my %dupes; + $dupes{$_}++ foreach $self->_default_inc(); @inc = grep !$dupes{$_}++, @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; +} + + =head2 C<_restore_PERL5LIB> $self->_restore_PERL5LIB;
This is in 2.43_02, which I'm releasing right now.