CPAN-FindDependencies
view release on metacpan or search on metacpan
t/cpandeps-script.t view on Meta::CPAN
use strict;
use warnings;
no warnings qw(qw); # suppress warnings about commas in text
use CPAN::FindDependencies qw(finddeps);
use Test::More;
use Test::Differences;
use Devel::CheckOS;
use Capture::Tiny qw(capture);
use Config;
# First, make sure that what we're about to test using the script works
# when using the module directly
{
local $SIG{__WARN__} = sub { my @w = grep { $_ !~ /no metadata/ } @_; warn(@w) if(@w) };
eq_or_diff(
{
map {
$_->name() => [$_->depth(), $_->distribution(), $_->warning() ? 1 : 0]
}
finddeps(
'Tie::Scalar::Decay',
mirror => 'DEFAULT,t/cache/Tie-Scalar-Decay-1.1.1/02packages.details.txt.gz',
cachedir => 't/cache/Tie-Scalar-Decay-1.1.1',
)
},
{
'Tie::Scalar::Decay' => [0, 'D/DC/DCANTRELL/Tie-Scalar-Decay-1.1.1.tar.gz', 1]
},
"Fetching directly from the library works"
);
}
SKIP: {
skip "Script works but tests don't on Windows. Dunno why.", 1
if(Devel::CheckOS::os_is('MicrosoftWindows'));
SKIP: {
skip "Can't be root for these tests", 1
if($< == 0);
subtest "Can't create the cachedir", sub {
my $fail_to_create_dir = '/foo';
$fail_to_create_dir .= 'x' while(-e $fail_to_create_dir);
my ($stdout, $stderr, $exit) = capture { system(
$Config{perlpath}, (map { "-I$_" } (@INC)),
qw(
blib/script/cpandeps
Tie::Scalar::Decay
mirror DEFAULT,t/cache/Tie-Scalar-Decay-1.1.1/02packages.details.txt.gz
cachedir
),
$fail_to_create_dir
)};
$stderr = join("\n", grep { $_ !~ / ^ Devel::Hide.*Test.Pod /x } split(/[\r\n]+/, $stderr));
eq_or_diff($stderr, "Bad cachedir: $fail_to_create_dir", "Error message when can't create cachedir");
ok($exit, "Got non-zero exit code");
eq_or_diff($stdout, "", "Nothing on STDOUT");
};
};
subtest "cachedir doesn't exist but can be created", sub {
my $can_create_dir= "/tmp/CPAN-FindDependencies-cachedir-create-test/OMG";
$can_create_dir .= 'x' while(-e $can_create_dir);
my ($stdout, $stderr, $exit) = capture { system(
( run in 0.512 second using v1.01-cache-2.11-cpan-6aa56a78535 )