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
|
use strict;
use warnings;
use utf8;
use Test::More;
use Devel::CheckBin;
use File::Temp;
my $cmd = $^O eq 'MSWin32' ? "find" : "ls";
subtest 'ok' => sub {
plan skip_all => "no $cmd" unless can_run("$cmd");
my $out;
{
local *STDOUT;
open *STDOUT, '>', \$out;
check_bin("$cmd");
}
like $out, qr{Locating bin:$cmd\.\.\. found at \S+};
pass "OK";
};
subtest 'fail' => sub {
my $fh = File::Temp->new();
print {$fh} q{use Devel::CheckBin; check_bin( 'unknown_command_name_here' ); };
$fh->close;
my $err = `"$^X" -Ilib $fh 2>&1`;
like ($err, qr/Please install 'unknown_command_name_here' seperately and try again./ms,
"missing 'unknown_command_name_here'"
);
};
done_testing;
|