On Tue, Jul 7, 2009 at 3:15 AM, Michael G Schwern<schw...@pobox.com> wrote:
> use lib 't/lib';
> chdir 't';
> require Some::Module::In::t::lib;
>
> lib.pm does not make the directory absolute, so it leaves your program
> vulnerable to the above problem.  Its rare you'd have to require instead of
> use, some load order issues make it necessary, but it sure it annoying when it
> happens.

I'll generally go with the convention of having a 't/lib', and adding
that via 'use lib qw( t/lib)'.  Within there, all packages are
prefixed with 't' also, so for testing Foo package, the relevant test
libs will be located in 't/lib/t/Foo', and the package names being
't::Foo'.  This was initially adopted because Test::Class [1]
historically (maybe still) had problems with some package names
conflicting with inner packages used by itself.  It also has the
benefit of being able to easily determine which are test packages and
which are part of the application itself.

Mark.

[1] Test::Class is my preferred testing package for work; I don't use
it for stuff destined for CPAN due to adding an extra dependancy.
*sigh*

Reply via email to