On 12/23/2009 03:30:49 AM, Shlomi Fish wrote:
> On Wednesday 23 Dec 2009 00:05:40 Ben Morrow wrote:
> > Quoth [email protected] (Geoffrey Leach):
> > > I'm working on a new release of Getopt::Auto. There's a fair
> amount of
> > > code in the module that applies only to the tests. It would be
> nice if
> > > that code was not in the installed module. Any suggestions?
> > 
> > Given that Perl allows you to put code in any package from any
> module,
> > can you just have a module in your t/ dir that implements the
> testing
> > hooks? Personally I like to put such modules in the t:: namespace,
> since
> > tests are always run from the module build directory, so I might
> call it
> > t::Hooks or some such.
> 
> What I normally do is put it under t/lib (say 
> t/lib/Config/IniFiles/TestFiles.pm) and then do:
> 
> <<<
> use lib "./t/lib";
> 
> use Config::IniFiles::Testfiles;
> use Config::IniFiles::OtherHelperModule;
> # Etc.
> >>>
> 
> This is cleaner than calling the module itself "t::", as modules that
> start 
> with a lowercase letter should be pragmata.
> 
> Regards,
> 
>       Shlomi Fish

Thanks to Shlomi and all who replied. I elected to use the 'use lib "./
t/lib' paradim and then discovered something rather unusual. 
Getopt::Auto has code that is run in the CHECK and INIT blocks as well 
as an import() subroutine. Appartently this interacts somehow with the 
subsidiary lib. For example,

require TestSupport;
...
TestSupport::foo()

results in "Undefined subroutine &TestSupport::foo ..."
but bare "foo()" works fine. TestSupport.pm does not export.

Perhaps I can figure this out one day :-)


Reply via email to