Alien-Build
view release on metacpan or search on metacpan
t/alien_build.t view on Meta::CPAN
ok(-d $share, "directory created" );
is $gather, 1, 'ran gather';
ok( -f $share->child('_alien/alien.json'), 'has alien.json');
ok( -f $share->child('_alien/alienfile'), 'has alienfile');
};
};
subtest 'checkpoint' => sub {
my $root = Path::Tiny->tempdir;
my $alienfile = Path::Tiny->tempfile( TEMPLATE => 'alienfileXXXXXXX' );
$alienfile->spew(q{
use alienfile;
meta_prop->{foo1} = 'bar1';
});
subtest 'create checkpoint' => sub {
my $build = Alien::Build->load("$alienfile", root => "$root");
is($build->meta_prop->{foo1}, 'bar1');
$build->install_prop->{foo2} = 'bar2';
$build->runtime_prop->{foo3} = 'bar3';
$build->checkpoint;
ok( -r path($build->root, 'state.json') );
};
subtest 'resume checkpoint' => sub {
my $build = Alien::Build->resume("$alienfile", "$root");
is($build->meta_prop->{foo1}, 'bar1');
is($build->install_prop->{foo2}, 'bar2');
is($build->runtime_prop->{foo3}, 'bar3');
};
};
subtest 'patch' => sub {
subtest 'single' => sub {
my $build = alienfile_ok q{
use alienfile;
plugin 'Test::Mock',
probe => 'share',
download => 1,
extract => {
file1 => 'The quick brown dog jumps over the lazy dog',
file2 => 'text2',
};
share {
patch sub {
Path::Tiny->new('file1')->edit(sub { s/dog/fox/ });
};
build sub {
my($build) = @_;
Path::Tiny->new('file1')->copy(Path::Tiny->new($build->install_prop->{stage})->child('file3'));
};
};
};
alien_install_type_is 'share';
alien_download_ok;
alien_extract_ok;
alien_build_ok;
is(
path($build->install_prop->{stage})->child('file3')->slurp,
'The quick brown fox jumps over the lazy dog',
);
};
subtest 'double' => sub {
my $build = alienfile_ok q{
use alienfile;
plugin 'Test::Mock',
probe => 'share',
download => 1,
extract => {
file1 => 'The quick brown dog jumps over the lazy dog',
file2 => 'The quick brown fox jumps over the lazy fox',
};
share {
patch sub {
# fix the saying in file1
Path::Tiny->new('file1')->edit(sub { s/dog/fox/ });
};
patch sub {
# fix the saying in file 2
Path::Tiny->new('file2')->edit(sub { s/fox$/dog/ });
};
build sub {
my($build) = @_;
Path::Tiny->new('file1')->copy(Path::Tiny->new($build->install_prop->{stage})->child('file3'));
Path::Tiny->new('file2')->copy(Path::Tiny->new($build->install_prop->{stage})->child('file4'));
};
};
};
alien_install_type_is 'share';
alien_download_ok;
alien_extract_ok;
alien_build_ok;
my $file3 = path($build->install_prop->{stage})->child('file3');
is(
$file3->slurp,
'The quick brown fox jumps over the lazy dog',
);
my $file4 = path($build->install_prop->{stage})->child('file4');
is(
$file4->slurp,
'The quick brown fox jumps over the lazy dog',
);
};
};
subtest 'preload' => sub {
{ package Alien::Build::Plugin::Preload1;
$INC{'Alien/Build/Plugin/Preload1.pm'} = __FILE__;
use Alien::Build::Plugin;
sub init
{
my($self, $meta) = @_;
$meta->register_hook('preload1' => sub {});
}
}
{ package Alien::Build::Plugin::Preload1::Preload2;
$INC{'Alien/Build/Plugin/Preload1/Preload2.pm'} = __FILE__;
use Alien::Build::Plugin;
sub init
{
my($self, $meta) = @_;
$meta->register_hook('preload2' => sub {});
}
}
local $ENV{ALIEN_BUILD_PRELOAD} = join ';', qw( Preload1 Preload1::Preload2 );
my $build = alienfile filename => 'corpus/blank/alienfile';
my $meta = $build->meta;
ok( $meta->has_hook($_), "has hook $_" ) for qw( preload1 preload2 );
};
subtest 'first probe returns share' => sub {
( run in 0.912 second using v1.01-cache-2.11-cpan-5623c5533a1 )