On Sat, Dec 01, 2007 at 01:38:35AM +0100, A. Pagaltzis wrote:
>     plan eval { require Net::CIDR }
>         ? tests    => 6
>         : skip_all => 'failed to load Net::CIDR';

This is what I ended up doing (didn't check if I'm reinventing the
wheel).  Instead of "use Test::More" I'm doing:

    use MyTest
        tests   => 16,
        recommended => [qw/ DateTime DBI Foo /];

Then:

    package MyTest;
    use strict;
    use warnings;
    use base 'Exporter';
    use Test::More;

    @MyTest::EXPORT = @Test::More::EXPORT;


    sub import {
        my ( $self, %options ) = @_;

        __PACKAGE__->export_to_level( 1, __PACKAGE__ );


        if ( my $mods = $options{recommended} ) {
            for (  ref $mods ? @$mods : $mods ) {
                unless ( eval "require $_" ) {
                    plan skip_all => "Missing recommended module [$_]";
                    return;
                }
            }
        }

        plan tests => $options{tests} if $options{tests};
    }


    1;


Exporter docs recommend:

    __PACKAGE__->export_to_level(1, @_);

But when I pass along all arguments I get:

    MyTest does not define $MyTest::VERSION--version check failed at
    /usr/share/perl/5.8/Exporter/Heavy.pm line 107.

Which I guess makes sense for Exporter.


-- 
Bill Moseley
[EMAIL PROTECTED]

Reply via email to