CPANPLUS-Dist-Build

 view release on metacpan or  search on metacpan

t/02_CPANPLUS-Dist-Build.t  view on Meta::CPAN

use ExtUtils::Installed;

my $Class   = 'CPANPLUS::Dist::Build';
my $Utils   = 'CPANPLUS::Internals::Utils';
my $Have_CC =  can_run($Config{'cc'} )? 1 : 0;
my $Usedl   = $Config{usedl} ? 1 : 0;


my $Lib     = File::Spec->rel2abs(File::Spec->catdir( qw[dummy-perl] ));
my $Src     = File::Spec->rel2abs(File::Spec->catdir( qw[src] ));

my $Verbose = @ARGV ? 1 : 0;
my $Conf    = gimme_conf();
my $CB      = CPANPLUS::Backend->new( $Conf );

#$Conf->set_conf( base       => 'dummy-cpanplus' );
#$Conf->set_conf( dist_type  => '' );
#$Conf->set_conf( verbose    => $Verbose );
#$Conf->set_conf( signature  => 0 );
### running tests will mess with the test output so skip 'm
#$Conf->set_conf( skiptest   => 1 );

### create a fake object, so we don't use the actual module tree
### make sure to add dslip data, so CPANPLUS doesn't try to find
### it in another module in the package, for which it needs the
### module tree
my $Mod = CPANPLUS::Module::Fake->new(
                module  => 'Foo::Bar',
                path    => 'src',
                author  => CPANPLUS::Module::Author::Fake->new,
                package => 'Foo-Bar-0.01.tar.gz',
                dslip   => 'RdpO?',
            );

### dmq tells us that we should run with /nologo
### if using nmake, as it's very noise otherwise.
### XXX copied from CPANPLUS' test include file!
{   my $make = $Conf->get_program('make');
    if( $make and basename($make) =~ /^nmake/i and
        $make !~ m|/nologo|
    ) {
        $make .= ' /nologo';
        $Conf->set_program( make => $make );
    }
}


                # path, cc needed?
my %Map     = ( noxs    => 0,
                xs      => 1
            );


### Disable certain possible settings, so we dont accidentally
### touch anything outside our sandbox
{
    ### set buildflags to install in our dummy perl dir
    $Conf->set_conf( buildflags => "install_base=$Lib" );

    ### don't start sending test reports now... ###
    $CB->_callbacks->send_test_report( sub { 0 } );
    $Conf->set_conf( cpantest => 0 );

    ### we dont need sudo -- we're installing in our own sandbox now
    $Conf->set_program( sudo => undef );
}

use_ok( $Class );

ok( $Class->format_available,   "Format is available" );


while( my($path,$need_cc) = each %Map ) {

    my $mod = $Mod->clone;
    ok( $mod,                   "Module object created for '$path'" );

    ### set the fetch location -- it's local
    {   my $where = File::Spec->rel2abs(
                            File::Spec->catfile( $Src, $path, $mod->package )
                        );

        $mod->status->fetch( $where );

        ok( -e $where,          "   Tarball '$where' exists" );
    }

    ok( $mod->prepare,          "   Preparing module" );

    ok( $mod->status->dist_cpan,
                                "   Dist registered as status" );

    isa_ok( $mod->status->dist_cpan, $Class );

    ok( $mod->status->dist_cpan->status->prepared,
                                "   Prepared status registered" );
    is( $mod->status->dist_cpan->status->distdir, $mod->status->extract,
                                "   Distdir status registered properly" );


    is( $mod->status->installer_type, INSTALLER_BUILD,
                                "   Proper installer type found" );


    ### we might not have a C compiler
    SKIP: {
        skip("Perl wasn't built with support for dynamic loading " .
             "-- skipping compile tests", 5) unless $Usedl;
        skip("The CC compiler listed in Config.pm is not available " .
             "-- skipping compile tests", 5) if $need_cc && !$Have_CC;
        skip("Module::Build is not compiled with C support ".
             "-- skipping compile tests", 5)
             unless $Module::Build::VERSION >= 0.36 ||
             eval { require Module::Build::ConfigData;
                    Module::Build::ConfigData->feature('C_support') };

        ok( $mod->create( ),    "Creating module" );

        ok( $mod->status->dist_cpan->status->created,
                                "   Created status registered" );



( run in 1.923 second using v1.01-cache-2.11-cpan-437f7b0c052 )