Alien-Build
view release on metacpan or search on metacpan
t/alien_build_mm.t view on Meta::CPAN
field 'Share::Foo' => '4.567';
};
field PREREQ_PM => hash {
field 'Alien::Build' => T();
};
etc;
},
);
};
};
subtest 'mm_postamble' => sub {
local $CWD = tempdir( CLEANUP => 1 );
my $build = alienfile q{
use alienfile;
probe sub { 'system' };
};
my $abmm = Alien::Build::MM->new;
$abmm->mm_args(
DISTNAME => 'Alien-Foo',
);
my $postamble = $abmm->mm_postamble;
ok $postamble, 'returned a true value';
note $postamble;
};
subtest 'set_prefix' => sub {
foreach my $type (qw( perl site vendor ))
{
subtest "type = $type" => sub {
local $CWD = tempdir( CLEANUP => 1 );
alienfile q{
use alienfile;
probe sub { 'share' };
};
my @dirs = map { path($CWD)->child('foo')->child($_) } qw( perl site vendor );
$_->mkpath for @dirs;
do {
my $abmm = Alien::Build::MM->new;
$abmm->mm_args(
DISTNAME => 'Alien-Foo',
);
};
note capture_merged {
local @ARGV = ($type, @dirs);
prefix();
};
ok( -f '_alien/mm/prefix', 'touched prefix' );
my $build = Alien::Build->resume('alienfile', '_alien');
my $prefix = path($build->runtime_prop->{prefix})->relative($CWD)->stringify;
is $prefix, "foo/$type/auto/share/dist/Alien-Foo", "correct path";
};
}
};
subtest 'download + build' => sub {
local $CWD = tempdir( CLEANUP => 1 );
$main::call_download = 0;
$main::call_build = 0;
alienfile q{
use alienfile;
plugin 'Test::Mock',
probe => 'share',
check_digest => 1;
use Path::Tiny qw( path );
share {
download sub {
my($build) = @_;
my $path = path('foo.tar.gz')->absolute;
$path->spew('foo');
$build->install_prop->{download_detail}->{"$path"} = {
protocol => 'file',
digest => [ FAKE => 'deadbeaf' ],
};
print " + IN DOWNLOAD +\n";
$main::call_download = 1;
};
extract sub {
print " + IN EXTRACT +\n";
path('file1')->spew('foo1');
path('file2')->spew('foo2');
};
build sub {
print " + IN BUILD +\n";
$main::call_build = 1;
};
};
};
my $abmm = Alien::Build::MM->new;
$abmm->mm_args(
DISTNAME => 'Alien-Foo',
);
note capture_merged {
local @ARGV = ('perl', map { ($_,$_,$_) } tempdir( CLEANUP => 1 ));
prefix();
};
my($out, $error) = capture_merged {
local @ARGV = ();
eval { download() };
$@;
};
note $out if $out ne '';
is($error, '', 'no error in download') || do {
diag _dump(get_build()->install_prop);
return;
};
note _dump(get_build()->install_prop);
ok( -f '_alien/mm/download', 'touched download' );
is $main::call_download, 1, 'download';
($out, $error) = capture_merged {
local @ARGV = ();
eval { build() };
$@;
};
note $out if $out ne '';
is($error, '', 'no error in build') || do {
diag _dump(get_build()->install_prop);
return;
};
note _dump(get_build()->install_prop);
ok( -f '_alien/mm/build', 'touched build' );
is $main::call_build, 1, 'build';
};
subtest 'patch' => sub {
local $CWD = tempdir( CLEANUP => 1 );
alienfile q{
use alienfile;
};
path('patch')->mkpath;
path('patch/foo.txt')->touch;
my $abmm = Alien::Build::MM->new;
ok( $abmm->build->install_prop->{patch}, 'patch is defined' );
ok( -f path($abmm->build->install_prop->{patch})->child('foo.txt'), 'got the correct directory' );
};
subtest 'clean_install' => sub {
local $CWD = tempdir( CLEANUP => 1 );
alienfile q{
use alienfile;
probe sub { 'share' };
};
my @dirs = map { path($CWD)->child('foo')->child($_) } qw( perl site vendor );
$_->mkpath for @dirs;
my $abmm = Alien::Build::MM->new( clean_install => 1 );
is( $abmm->clean_install, T() );
my %args = $abmm->mm_args( DISTNAME => 'AlienFoo' );
is(
\%args,
hash {
field CONFIGURE_REQUIRES => hash {
field 'Alien::Build::MM' => '1.74';
etc;
};
field BUILD_REQUIRES => hash {
field 'Alien::Build::MM' => '1.74';
etc;
( run in 0.537 second using v1.01-cache-2.11-cpan-e1769b4cff6 )