Alien-Build
view release on metacpan or search on metacpan
t/alien_build_plugin_probe_cbuilder.t view on Meta::CPAN
use 5.008004;
use Test2::V0 -no_srand => 1;
use Test::Alien::Build;
use lib 't/lib';
use MyTest::System;
use Alien::Build::Plugin::Probe::CBuilder;
use Capture::Tiny qw( capture_merged );
use Path::Tiny qw( path );
subtest 'basic' => sub {
my $mock = mock 'ExtUtils::CBuilder';
my @args_new;
my @args_compile;
my @args_link_executable;
$mock->add('new' => sub {
shift;
@args_new = @_;
bless {}, 'ExtUtils::CBuilder';
});
$mock->add('compile' => sub {
shift;
@args_compile = @_;
'mytest.o';
});
$mock->add('link_executable' => sub {
shift;
@args_link_executable = @_;
'mytest';
});
my $build = alienfile_ok q{
use alienfile;
plugin 'Probe::CBuilder' => (
cflags => '-I/usr/local/include',
libs => '-L/usr/local/lib -lfoo',
options => { foo1 => 1, bar1 => 2 },
);
};
my $gard = system_fake
'./mytest' => sub { 0 },
'mytest' => sub { 0 },
;
alien_build_ok;
alien_install_type_is 'system';
is( $build->runtime_prop->{cflags}, '-I/usr/local/include ', 'cflags' );
is( $build->runtime_prop->{libs}, '-L/usr/local/lib -lfoo ', 'libs' );
is( { @args_new }, { foo1 => 1, bar1 => 2 }, 'options passed to new' );
is(
{ @args_compile },
hash {
field source => T();
field extra_compiler_flags => '-I/usr/local/include';
etc;
},
( run in 1.160 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )