On Mon, Sep 02, 2002 at 08:13:06AM +0100, Nick Ing-Simmons wrote:
> I understand all that. My point was that while test itself may care 
> where it is run, blib.pm does not mind as much. Also blib.pm's job 
> is to make running an un-installed module "easy" which is what you 
> want to do for a pre-install test. So if there is boiler-plate stuff 
> to do blib.pm is an appropriate place to do it.
> 
> Thus is you need to be in t this might suit
> 
>   cd t; perl -Mblib=lib foo/bar.t
> 
> would work, and I would be more than happy it it looked for a t directory 
> as well.

There's a chicken/egg problem here.  blib.pm is going to find the lib/
directory so we can load uninstalled modules.  So... how do you find
blib.pm?

I believe the above worked for you because you happen to have an already
installed perl in the same spot as the new one is going to go.  If you move
that out of the way, no good.

Other problems include that we can't assume blib.pm works.  Don't want the
whole basic test suite falling apart because of a module failure.

Finally, since you have to run from t/ anyway, blib.pm is overkill.  This
works just as well:

    cd t;  ./perl -I../lib foo/bar.t

Anyhow, t/TestInit.pm *already does this*.

schwern@blackrider:/usr/local/src/perl-current$ ./perl -It -MTestInit -wle 'print 
@INC;  use Cwd;  print cwd;'
.../lib
/usr/local/src/perl-current/t

While the result is still ugly, it means we can expand and alter the
requirements for running a core test.  For example, the PERL_CORE
environment variable should be set (t/TestInit.pm currently doesn't).  So
the full command is really something like this:

    cd t;
    PERL_CORE=1 ./perl -I../lib path/to/test.t

Which could be reduced somewhat to:

    ./perl -It -MTestInit t/path/to/test.t

and perhaps reduced a little further by moving/linking TestInit.pm into the
top level directory.

    ./perl -MTestInit t/path/to/test.t

but that will cause trouble when running tests with -T (because . is no
longer in the path).

When tests are run using t/TEST (ie. "make test") are run with TestInit.  So
strictly speaking the BEGIN block is redundant.  t/harness (ie. "make
test_harness") is currently not using TestInit.  There's currently a bug
where $Test::Harness::switches is not honored.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
MERV GRIFFIN!

Reply via email to