There's already the beginnings of something like this in t/TestInit.pm, but
it wasn't updated for the PERL_CORE trick.  Nor do I know if it can be
entirely trusted.

Also, Nick's example is a little odd.  You usually don't want '.' (ie. t/)
in your @INC.  It's more like this:

    BEGIN {
        if($ENV{PERL_CORE}) {
            chdir 't';
            @INC = '../lib';
        }
    }

but in some cases you need to include something more.  For example,
MakeMaker does this:

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

so it can see specialty helper modules in t/lib/.


----- Forwarded message from Ken Williams <[EMAIL PROTECTED]> -----

From: Ken Williams <[EMAIL PROTECTED]>
Date: Thu, 29 Aug 2002 14:08:00 +1000
To: Nicholas Clark <[EMAIL PROTECTED]>
Subject: Re: [Inline 0.43] insecure dependency when tainting

On Thursday, August 29, 2002, at 06:51 AM, Nicholas Clark wrote:
>You'll often see regression tests in the core start like this:
>
>sub BEGIN {
>    if ($ENV{PERL_CORE}){
>       chdir('t') if -d 't';
>       @INC = ('.', '../lib');
>    } else {
>       unshift @INC, 't';
>    }
>
>
>if $ENV{PERL_CORE} is set, then the test knows that it's being 
>run as part
>of a core build, and so it should force @INC to only find uninstalled
>modules in the core tree.

Seems like it would be nicer to set that externally, rather than 
in every test file.  Maybe some code like this could be added to 
blib.pm or something?  Then one could do something like this:

 perl -Mblib=only t/foo.t


>Sorry if I've wasted your time by telling you something you 
>already knew,
>or had inferred from Hugo's reply.

I might have inferred it, but this helped me understand various 
implications, actually.

 -Ken




----- End forwarded message -----

-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
Try explaining that to my brain which is currently ON FIRE!
        http://www.goats.com/archive/010704.html

Reply via email to