FFI-Platypus
view release on metacpan or search on metacpan
t/ffi_probe.t view on Meta::CPAN
use Test2::V0 -no_srand => 1;
use 5.008004;
use FFI::Probe;
use FFI::Probe::Runner;
use Capture::Tiny qw( capture_merged );
use FFI::Temp;
use File::Basename qw( basename );
use Config;
sub n (&)
{
my($code) = @_;
my($out, @ret) = capture_merged {
$code->();
};
note $out;
@ret;
}
sub f (@)
{
foreach my $filename (@_)
{
note "==@{[ basename $filename ]}==";
my $fh;
open $fh, '<', $filename;
note do { local $/; <$fh> };
close $fh;
}
}
my $runner = do {
my $exe = "blib/lib/auto/share/dist/FFI-Platypus/probe/bin/dlrun$Config{exe_ext}";
unless(-f $exe)
{
require FFI::Probe::Runner::Builder;
my $out;
my $exception;
($out, $exe, $exception) = capture_merged {
my $exe = eval {
FFI::Probe::Runner::Builder->new( dir => FFI::Temp->newdir( CLEANUP => 1, TEMPLATE => 'test-probe-XXXXXX' ) )->build;
};
($exe, $exception);
};
note $out;
die $exception if $exception;
}
FFI::Probe::Runner->new(
exe => $exe,
);
};
subtest 'check_header' => sub {
my $dir = FFI::Temp->newdir;
my $probe = FFI::Probe->new(
log => "$dir/probe.log",
data_filename => "$dir/probe.pl",
runner => $runner,
);
isa_ok $probe, 'FFI::Probe';
n {
$probe->check_header('stdio.h');
$probe->check_header('bogus/does/not/exist.h');
};
is($probe->data->{header}->{"stdio.h"}, 1);
is($probe->data->{header}->{"bogus/does/not/exist.h"}, 0);
undef $probe;
f "$dir/probe.log",
"$dir/probe.pl";
( run in 1.935 second using v1.01-cache-2.11-cpan-54e63673c56 )