Alien-Build
view release on metacpan or search on metacpan
t/alien_build_plugin_probe_commandline.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::CommandLine;
use Capture::Tiny qw( capture_merged );
sub cap (&)
{
my($code) = @_;
my($out, $ret) = capture_merged { $code->() };
note $out if $out;
$ret;
}
sub build
{
my $build = alienfile_ok q{ use alienfile };
my $meta = $build->meta;
if(ref $_[-1] eq 'CODE')
{
my $code = pop;
$code->($build, $meta);
}
my $plugin = Alien::Build::Plugin::Probe::CommandLine->new(@_);
$plugin->init($meta);
($build, $plugin, $meta);
}
subtest 'basic existence' => sub {
my $guard = system_fake
'foo' => sub { return 0 },
;
subtest 'it is there' => sub {
my($build) = build('foo');
is cap { $build->probe }, 'system', 'is system';
};
subtest 'it is not there' => sub {
my($build) = build('bar');
is cap { $build->probe }, 'share', 'is share';
};
};
subtest 'args' => sub {
my $called = 0;
my @args;
my $guard = system_fake
'foo' => sub { $called = 1; @args = @_; return 0 },
;
my($build) = build(command => 'foo', args => [1,2,3], match => qr// );
( run in 1.400 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )