PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/t/metaonly.t

http://github.com/dagolden/app-mymeta_requires
Unknown | 66 lines | 61 code | 5 blank | 0 comment | 0 complexity | 11f5e5f5f60600c4dd7cf18c5ad39a4c MD5 | raw file
 1use 5.006;
 2use strict;
 3use warnings;
 4use Capture::Tiny qw/capture/;
 5use File::pushd qw/pushd/;
 6use File::Spec::Functions qw/catdir/;
 7use Test::Deep;
 8use Test::More 0.92;
 9
10use App::mymeta_requires;
11
12# Everything listed in t/data/metaonly/META.json file
13# We should usually never have X::Configure::Requires because those would
14# have to be satisfied before MYMETA is created, but we force it with
15# a bogus module
16my %all_reqs = map { $_ => 1 } qw(
17  X::Configure::Requires
18  X::Runtime::Requires
19  X::Runtime::Recommends
20  X::Runtime::Suggests
21  X::Build::Requires
22  X::Test::Requires
23  X::Develop::Requires
24);
25
26my @cases = (
27  {
28    options =>  [],
29    remove =>   [ qw/X::Develop::Requires/ ],
30  },
31  {
32    options =>  [ qw/--develop/ ],
33    remove =>   [  ],
34  },
35  {
36    options =>  [ qw/--no-suggests/ ],
37    remove =>   [ qw/X::Runtime::Suggests X::Develop::Requires/ ],
38  },
39  {
40    options =>  [ qw/--no-recommends/ ],
41    remove =>   [ qw/X::Runtime::Recommends X::Develop::Requires/ ],
42  },
43  {
44    options =>  [ qw/--no-build --develop/ ],
45    remove =>   [ qw/X::Build::Requires/ ],
46  },
47  {
48    options =>  [ qw/--no-configure --develop/ ],
49    remove =>   [ qw/X::Configure::Requires/ ],
50  },
51);
52
53for my $c ( @cases ) {
54  my $wd = pushd( catdir( qw/t data metaonly/ ) );
55  my @options = @{$c->{options}};
56  my $label = @options ? join(" ", @options) : "(default)";
57  local @ARGV = (@options);
58  my $app = App::mymeta_requires->new;
59  my %expected = %all_reqs;
60  delete $expected{$_} for @{ $c->{remove} };
61  my $output = capture { $app->run };
62  cmp_deeply( [split "\n", $output], bag(sort keys %expected), $label );
63}
64
65done_testing;
66# COPYRIGHT