On Thu, Apr 11, 2002 at 12:16:27PM -0500, Andy Lester wrote:
> 
> I'm using Test::More for doing infrastructure testing throughout my
> project.  One of the tests I'm doing is making sure that every .pm file is
> able to load on its own, since I've had problems where the .pm had
> dependencies on other modules, but so long as the calling program included
> those modules first, the problem would remain hidden.

One simple way around this is to use SelfTest or Test::Inline and
throw in at the top of each of your modules:

    =for testing
    use_ok('My::Self');

and then just run the tests in each self-testing module in turn.


> So I have a test where I do a use_ok( 'Foo::Bar' ).  All fine and good.
> What I'd like is a way to do use_ok( 'Foo' ) and a use_ok( 'Bar' ), but
> somehow make sure that the order of checking these not matter.  Even in an
> eval {}, my namespace is going to be polluted after the first use_ok(),
> sin't it?

What you want, basically, is the ability to quickly and easily run
perl code in a seperate process.  If you're on Unix you can just
fork().  Otherwise you have to make a system() call to Perl.

In the Perl core there's a file t/test.pl.  This reimplements most of
Test::More's features, but in a much more conservative way to avoid
using the very features that you're testing.  It also contains a
handful of interesting new functions above and beyond Test::More.  One
of these is fresh_perl() which runs a given chunk of code in a fresh
Perl process in a cross-platform manner.  It's usually used to test
code that will cause a segfault, but's useful for what you want, too.

I've been meaning to make a CPAN version of this code, but I'm out of
tuits.


-- 

Michael G. Schwern   <[EMAIL PROTECTED]>    http://www.pobox.com/~schwern/
Perl Quality Assurance      <[EMAIL PROTECTED]>         Kwalitee Is Job One
11. Every old idea will be proposed again with a different name and
    a different presentation, regardless of whether it works.
     -- RFC 1925

Reply via email to