File: dz2-hidden-provides.t

package info (click to toggle)
libdist-zilla-plugin-metaprovides-package-perl 2.004003-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 356 kB
  • sloc: perl: 421; makefile: 2
file content (94 lines) | stat: -rw-r--r-- 1,949 bytes parent folder | download | duplicates (3)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use strict;
use warnings;

use Test::More 0.96;
use Test::Fatal;
use Test::Moose;
use Path::Tiny qw( path );
use Test::DZil qw( simple_ini Builder );

my $test_config = [
  ['GatherDir'],    #
  [
    'MetaProvides::Package' => {
      inherit_version => 0,    #
      inherit_missing => 1,
    },
  ]
];

my $test_document = <<'EOF';
use strict;
use warnings;
package DZ2;

sub main {
  return 1;
}

package    # Hide me from indexing
  A::Hidden::Package;

sub hidden {
  return 2;
}

package A::_Local::Package;

sub private {
  return 3;
}

1;
__END__

=head1 NAME

DZ2

=cut
EOF

my $tzil = Builder->from_config(
  { dist_root => 'invalid' },
  {
    add_files => {
      path('source/lib/DZ2.pm') => $test_document,
      path('source/dist.ini')   => simple_ini(@{$test_config}),
    },
  },
);

$tzil->chrome->logger->set_debug(1);
$tzil->build;

my $plugin;

is(
  exception {
    $plugin = $tzil->plugin_named('MetaProvides::Package');
  },
  undef,
  'Found MetaProvides::Package'
);

isa_ok( $plugin, 'Dist::Zilla::Plugin::MetaProvides::Package' );
meta_ok( $plugin, 'Plugin is mooseified' );
does_ok( $plugin, 'Dist::Zilla::Role::MetaProvider::Provider', 'does the Provider Role' );
does_ok( $plugin, 'Dist::Zilla::Role::Plugin', 'does the Plugin Role' );
has_attribute_ok( $plugin, 'inherit_version' );
has_attribute_ok( $plugin, 'inherit_missing' );
has_attribute_ok( $plugin, 'meta_noindex' );
is( $plugin->meta_noindex, '1', "meta_noindex default is 1" );

# This crap is needed because 'ok' is mysteriously not working.
( not exists $plugin->metadata->{provides}->{'A::_Local::Package'} )
  ? pass('Packages leading with _ are hidden')
  : fail('Packages leading with _ are hidden');

( not exists $plugin->metadata->{provides}->{'A::Hidden::Package'} )
  ? pass('Packages with \n are hidden')
  : fail('Packages with \n are hidden');

isa_ok( [ $plugin->provides ]->[0], 'Dist::Zilla::MetaProvides::ProvideRecord' );
done_testing;