CPAN-FindDependencies
view release on metacpan or search on metacpan
t/cpandeps-diff-script.t view on Meta::CPAN
use strict;
use warnings;
use CPAN::FindDependencies qw(finddeps);
use Test::More;
use Test::Differences;
use Devel::CheckOS;
use Capture::Tiny qw(capture);
use Config;
use File::Path qw(remove_tree);
$ENV{CPANDEPS_DIFF_DIR} = '.';
remove_tree('.cpandeps-diff');
END {
remove_tree('.cpandeps-diff') if(Test::More->builder()->is_passing());
}
SKIP: {
skip "Windows is just weird", 1
if(Devel::CheckOS::os_is('MicrosoftWindows'));
my @default_cmd = (
$Config{perlpath}, (map { "-I$_" } (@INC)),
'blib/script/cpandeps-diff',
qw(perl 5.30.3)
);
my @mirror = qw(mirror t/mirrors/privatemirror);
my($stdout, $stderr) = capture { system( @default_cmd, 'help') };
like($stdout, qr/cpandeps.*diff.*add.*Some::Module/, "Can spew out some help");
($stdout, $stderr) = capture { system( @default_cmd, 'list') };
eq_or_diff($stdout, '', "Starting with an empty db");
note("Try to add without saying what to add");
($stdout, $stderr) = capture { system( @default_cmd, @mirror, 'add') };
eq_or_diff($stdout, '', "Nothing on STDOUT");
like($stderr, qr/You must provide an argument to 'add'/, "STDERR as expected");
note("Try to add properly");
($stdout, $stderr) = capture { system( @default_cmd, @mirror, qw(add Brewery)) };
eq_or_diff($stdout, '', "Nothing on STDOUT");
eq_or_diff($stderr, '', "Nothing on STDERR");
note("Same again");
($stdout, $stderr) = capture { system( @default_cmd, @mirror, qw(add Brewery)) };
eq_or_diff($stdout, '', "Nothing on STDOUT");
eq_or_diff($stderr, '', "Nothing on STDERR");
note("Test that args can be --args");
@default_cmd = (
$Config{perlpath}, (map { "-I$_" } (@INC)),
'blib/script/cpandeps-diff',
qw(--perl 5.30.3)
);
@mirror = qw(--mirror t/mirrors/privatemirror);
note("Add another module");
($stdout, $stderr) = capture { system( @default_cmd, @mirror, qw(add Fruit)) };
eq_or_diff($stdout, '', "Nothing on STDOUT");
eq_or_diff($stderr, '', "Nothing on STDERR");
note("List modules");
($stdout, $stderr) = capture { system( @default_cmd, qw(list)) };
eq_or_diff($stdout, join("\n", qw(Brewery Fruit))."\n", "Got expected list");
eq_or_diff($stderr, '', "Nothing on STDERR");
( run in 0.811 second using v1.01-cache-2.11-cpan-6aa56a78535 )