Greetings,

I've noticed that CPAN authors use a variety of
techniques to manipulate the run-time environment in
their test scripts.  Usually, it involves changing
directories and/or altering @INC. This one seem pretty
popular:

  BEGIN {
      if($ENV{PERL_CORE}) {  #What is "PERL_CORE"?
          chdir 't';
          @INC = '../lib';
      }
      else {
          unshift @INC, 't/lib';
      }
  }

Or sometimes you see this:

  use FindBin "$Bin";
  use lib "$Bin/../lib";

On the other hand, some test scripts have no such
code, thus relying on the user (or the Makefile) to be
in the right directory and setup @INC so that the
"right" modules are loaded (e.g. perl -Ilib
t/test_scrpt.t).  So what do you suggest for
best-practices here? Specifically...


* Should a test script have a shebang?  What should it
be?  Any flags on that?

* When run outside of 'make test', should the test
script force modules to load from the distro's lib or
blib directory by default?  Or should it just load
from the user's existing @INC (whatever it may be).

* Should a test script make any assumptions about the
CWD?  Is it fair/safe for the test script to change
directories?

* What's the best practice for testing-only libraries?
 Where do they go and how do you load them?  Is there
a naming convention that most people follow (e.g.
t::Foo::Bar).

Thanks.

-Jeff


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Reply via email to