Alien-Base-ModuleBuild
view release on metacpan or search on metacpan
t/alien_base_modulebuild.t view on Meta::CPAN
__PACKAGE__;
};
subtest 'installed, not forced' => sub {
local $Alien::Base::ModuleBuild::Force = 0;
my $builder = builder( alien_bin_requires => { 'Foo::Bar' => '1.1' } );
is $builder->build_requires->{"Foo::Bar"}, undef, 'Foo::Bar = undef';
};
subtest 'installed, forced' => sub {
local $Alien::Base::ModuleBuild::Force = 1;
my $builder = builder( alien_bin_requires => { 'Foo::Bar' => '1.1' } );
is $builder->build_requires->{"Foo::Bar"}, '1.1', 'Foo::Bar = 1.1';
};
};
subtest 'system provides' => sub {
local $CWD = _new_temp();
local $mb_class = do {
package My::MBBuildSystemProvidesExample;
use base qw( Alien::Base::ModuleBuild );
sub alien_check_installed_version {
return '1.0';
}
__PACKAGE__;
};
subtest 'not installed, not forced' => sub {
local $Alien::Base::ModuleBuild::Force = 0;
my $builder = builder( alien_provides_cflags => '-DMY_CFLAGS', alien_provides_libs => '-L/my/libs -lmylib' );
$builder->depends_on('code');
is $builder->config_data('system_provides')->{Cflags}, '-DMY_CFLAGS', 'cflags';
is $builder->config_data('system_provides')->{Libs}, '-L/my/libs -lmylib', 'libs';
};
};
subtest 'alien_env' => sub {
local $CWD = _new_temp();
local $ENV{BAZ} = 'baz';
my $builder = builder(
alien_helper => {
myhelper => '"my helper text"',
},
alien_env => {
FOO => 'foo1',
BAR => '%{myhelper}',
BAZ => undef,
},
alien_build_commands => [],
);
isa_ok $builder, 'Alien::Base::ModuleBuild';
my($out, $err, %status) = capture { $builder->alien_do_system([$^X, -e => 'print $ENV{FOO}']) };
is $status{stdout}, 'foo1', 'env FOO passed to process';
($out, $err, %status) = capture { $builder->alien_do_system([$^X, -e => 'print $ENV{BAR}']) };
is $status{stdout}, 'my helper text', 'alien_env works with helpers';
($out, $err, %status) = capture { $builder->alien_do_system([$^X, -e => 'print $ENV{BAZ}||"undef"']) };
is $status{stdout}, 'undef', 'alien_env works with helpers';
};
subtest 'cmake' => sub {
subtest 'default' => sub {
local $CWD = _new_temp();
my $builder = builder(
alien_bin_requires => { 'Alien::CMake' => 0 },
alien_build_commands => [],
);
isa_ok $builder, 'Alien::Base::ModuleBuild';
is $builder->build_requires->{"Alien::CMake"}, '0.07', 'require at least 0.07';
};
subtest 'more recent' => sub {
local $CWD = _new_temp();
my $builder = builder(
alien_bin_requires => { 'Alien::CMake' => '0.10' },
alien_build_commands => [],
);
isa_ok $builder, 'Alien::Base::ModuleBuild';
is $builder->build_requires->{"Alien::CMake"}, '0.10', 'keep 0.10';
};
};
subtest 'install location' => sub {
local $CWD = _new_temp();
my $builder = builder();
my $path = $builder->alien_library_destination;
# this is not good enough, I really wish I could introspect File::ShareDir, then again, I wouldn't need this test!
my $path_to_share = "auto/share/dist/My-Test";
$path_to_share =~ s{\\}{/}g if $^O eq 'MSWin32';
like $path, qr/\Q$path_to_share\E/, 'path looks good';
};
subtest 'validation' => sub {
local $CWD = _new_temp();
my $builder = builder(
module_name => 'My::Test::Module',
dist_version => '1.234.567',
);
ok( $builder->alien_validate_repo( {platform => undef} ), "undef validates to true");
( run in 0.632 second using v1.01-cache-2.11-cpan-df04353d9ac )