develooper Front page | perl.qa | Postings from July 2009

Re: Test module for tests in Perl module distro

Thread Previous | Thread Next
From:
Mark Morgan
Date:
July 7, 2009 02:09
Subject:
Re: Test module for tests in Perl module distro
Message ID:
f1a2bc2c0907070208n20816d9m273cce6b90e268ab@mail.gmail.com
On Tue, Jul 7, 2009 at 3:15 AM, Michael G Schwern<schwern@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*

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About