Re: Discussion/request on Test::More , have it add t/lib to @INC if -d

[email protected] (Eirik Berg Hanssen) Fri, 31 Jan 2014 16:17:53 +0100
Newsgroups perl.qa
Message-ID <CAHAeAG7ukb8CVyxY_oSH+Ke=jbvb=Xq1YGC8+LM4w2OT=i86cw@mail.gmail.com>
On Fri, Jan 31, 2014 at 2:50 PM, David Cantrell <[email protected]>wrote:

> That has a few caveats though.
>
> Your %INC will be a bit screwy, which may matter to some code. And it
> will fail to run MyPackage->import(), because t::lib::MyPackage::import
> doesn't exist.
>
>   $ cat t/lib/MyPackage.pm
>   package MyPackage;
>   sub import { print "import() was called\n" }
>   1;
>
>   $ perl -e 'use t::lib::MyPackage;'
>
>   $ perl -e 'use lib "t/lib";use MyPackage;'
>   import() was called
>
> There may be other hidden weirdness that I've forgotten about.
>


  Yeah; just name the package accordingly, and, screwy or not, it'll still
work:

package t::lib::MyPackage;
sub import { print "import() was called\n" }
1;

  :)


Eirik