1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
use 5.008004;
use lib 'corpus/lib';
use Test2::V0 -no_srand => 1;
use Test::Alien::Build;
use Alien::Build::Plugin::Build::Autoconf;
use Alien::Build::Util qw( _dump );
use Path::Tiny qw( path );
subtest 'basic' => sub {
my $plugin = Alien::Build::Plugin::Build::Autoconf->new;
isa_ok $plugin, 'Alien::Build::Plugin';
isa_ok $plugin, 'Alien::Build::Plugin::Build::Autoconf';
my $build = alienfile_ok q{ use alienfile };
my $meta = $build->meta;
$plugin->init($meta);
my $configure = $meta->interpolator->interpolate('%{configure}');
isnt $configure, '', "\%{configure} = $configure";
like $configure, qr{configure};
like $configure, qr{--with-pic};
is($build->meta_prop->{destdir}, 1);
is($meta->prop->{destdir}, 1);
};
subtest 'turn off --with-pic' => sub {
my $plugin = Alien::Build::Plugin::Build::Autoconf->new( with_pic => 0 );
is( $plugin->with_pic, 0 );
my $build = alienfile_ok q{ use alienfile };
my $meta = $build->meta;
$plugin->init($meta);
my $configure = $meta->interpolator->interpolate('%{configure}');
isnt $configure, '', "\%{configure} = $configure";
like $configure, qr{configure$};
};
subtest 'out-of-source' => sub {
skip_all 'test requires Archive::Tar' unless eval { require Archive::Tar; 1 };
local $Alien::Build::VERSION = '1.08';
my $build = alienfile_ok q{
use alienfile;
use Alien::Build::Util qw( _dump );
use Path::Tiny qw( path );
share {
meta->prop->{out_of_source} = 1;
plugin 'Download::Foo';
plugin 'Build::Autoconf' => (
with_pic => 0,
);
build sub {
my($build) = @_;
$build->log(_dump($build->install_prop));
path('file1')->touch;
my $prefix = $build->install_prop->{prefix};
$prefix =~ s{^([a-z]):/}{$1/}i if $^O eq 'MSWin32';
$build->log("prefix = $prefix");
my $file2 = path($ENV{DESTDIR})->child($prefix)->child('file2');
$file2->parent->mkpath;
$file2->touch;
};
};
};
$build->load_requires('share');
note _dump($build->install_prop);
subtest 'before build' => sub {
my $configure = $build->meta->interpolator->interpolate('%{configure}');
note "%{configure} = $configure";
ok 1;
};
alien_build_ok;
note _dump($build->install_prop);
subtest 'after build' => sub {
my $configure = $build->meta->interpolator->interpolate('%{configure}');
note "%{configure} = $configure";
my $regex = $^O eq 'MSWin32' ? qr/^sh (.*?)\s/ : qr/^(.*)\s/;
like $configure, $regex, 'matches';
if($configure =~ $regex)
{
my $path = path($1);
ok(-f $path, "configure is in the right spot" );
ok(-f $path->sibling('foo.c'), "foo.c is in the right spot" );
}
};
};
done_testing;
{
package
Alien::MSYS;
use File::Temp qw( tempdir );
BEGIN {
our $VERSION = '0.07';
$INC{'Alien/MSYS.pm'} = __FILE__;
}
my $path;
sub msys_path
{
if(!$path)
{
$path = tempdir( CLEANUP => 1);
}
$path;
}
}
|