On May-09, Abhijit A. Mahabal wrote:
> On Sat, 8 May 2004, Abhijit A. Mahabal wrote:
> 
> > I was writing a few tests for the P6 parser and ran into a weird problem.
> > If I have the following in a file in languages/perl6, it works as
> > expected:
> 
> [...]
> 
> > Now, if I put exactly the same contents in a file in
> > languages/perl6/t/parser, then I get the following error:
> 
> 
> Okay, I traced the problem to a "use FindBin" in P6C::Parser.pm. Is it
> okay to change
> 
>   use lib $FindBin::Bin/../../lib;
> 
> to
> 
>   use lib ../../lib;
> 
> or is there a good reason not to? 

Neither of those seems right to me. The first keys off of the position
of the binary, which could be anywhere with respect to the library
module you're in; the second is relative to whatever the current
directory is while you're running the script. I would think that
something like

  use File::Basename qw(dirname);
  use lib dirname($INC{"P6C/Parser.pm"})."/../../../../lib";

(untested and probably not quite the right path) would be better. Or
perhaps it should be ripped out entirely, and any script using
P6C::Parser should be required to set the lib path correctly? It
partly depends on whether we want to ensure that P6C::Parser
preferentially uses the Parse::RecDescent from parrot/lib rather than
a system-provided one. Which probably is not the case?

> The current version makes it necessary
> to put all files that "use P6C::Parser" in the same directory, and the
> change would allow:
> 
>       perl t/parser/foo.t
> 
> to work.

Just make sure

  cd t; perl parser/foo.t

works too.

Reply via email to