Skip Menu |

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

Report information
The Basics
Id: 70659
Status: open
Priority: 0/
Queue: Test-Harness

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

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



Subject: prove -b is iniconsistent with perl -Mblib
When running `prove -b ...` blib dirs are not added @INC the way they are in the blib.pm module. The blib.pm module "searches" for the blib in up to 5 parent directories. This is handy when blib/ and t/ are not in the same directory. I tried to workaround this using `prove -Mblib ...` but it appears that the changes blib.pm makes to @INC are not propagated across the fork() that prove does. App::Prove.pm: 530 if ( $self->blib ) { 531 push @libs, 'blib/lib', 'blib/arch'; 532 } blib.pm: 70 my $i = 5; 71 my($blib, $blib_lib, $blib_arch); 72 while ($i--) 73 { 74 $blib = File::Spec->catdir($dir, "blib"); 75 $blib_lib = File::Spec->catdir($blib, "lib"); 76 77 if ($^O eq 'MacOS') 78 { 79 $blib_arch = File::Spec->catdir($blib_lib, $MacPerl::Architecture); 80 } 81 else 82 { 83 $blib_arch = File::Spec->catdir($blib, "arch"); 84 } 85 86 if (-d $blib && -d $blib_arch && -d $blib_lib) 87 { 88 unshift(@INC,$blib_arch,$blib_lib); 89 warn "Using $blib\n" if $Verbose; 90 return; 91 } 92 $dir = File::Spec->catdir($dir, File::Spec->updir); 93 }
I made an attempt to fix by patching the logic from blib.pm into Prove.pm. Note this patch also changes the ordering of "blib/arch blib/lib" to be consistent with the normal Perl search order. This fixes my use case, I would appreciate any comments on problems this may have. --- App/Prove.pm~ 2011-09-01 09:21:04.959380204 -0700 +++ App/Prove.pm 2011-09-01 09:28:57.519380050 -0700 @@ -527,7 +527,26 @@ push @libs, 'lib'; } if ( $self->blib ) { - push @libs, 'blib/lib', 'blib/arch'; + my $i = 5; + my($blib, $blib_lib, $blib_arch); + my $dir = File::Spec->rel2abs("."); + while ($i--) { + $blib = File::Spec->catdir($dir, "blib"); + $blib_lib = File::Spec->catdir($blib, "lib"); + + if ($^O eq 'MacOS') { + $blib_arch = File::Spec->catdir($blib_lib, $MacPerl::Architecture); + } + else { + $blib_arch = File::Spec->catdir($blib, "arch"); + } + + if (-d $blib && -d $blib_arch && -d $blib_lib) { + push @libs, $blib_arch, $blib_lib; + last; + } + $dir = File::Spec->catdir($dir, File::Spec->updir); + } } if ( @{ $self->includes } ) { push @libs, @{ $self->includes };
Opps, didn't mean to change the status to Open.
On Thu Sep 01 12:42:01 2011, ZEEK wrote: Show quoted text
> Opps, didn't mean to change the status to Open.
Don't worry, it just happens. There's two issues here. One is scanning parent directories for blib. The other is the order in which blib/lib and blib/arch get added. prove -b doesn't try to emulate the behavior of blib.pm. The docs are pretty clear that it "adds 'blib/lib' and 'blib/arch' to the path for your tests". So before we change the behavior we should talk about the behavior. I hold that tests running predictably is important. If prove gropes its way up the filesystem it could encounter an unrelated blib and use that with no indication to the user what went wrong. The minor and uncommon inconvenience of blib being in another directory can be eliminated with as little as a symlink. To the second problem... the order of blib/lib and blib/arch is correct in that it matches what ExtUtils::MakeMaker and Module::Build do when they run the tests. It is incorrect in that it is opposite what perl does. It's interesting that it hasn't really bitten anyone, it should probably match what perl does. I don't think it's actually consequential, and if it is changed that should be coordinated. Meanwhile, prove should follow what "make test" and "build test" do in order to prevent adding mysterious bugs. I'd talk about it with the Module::Build folks, see what they want to do.