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
|
use strict;
use warnings;
use Test::More 0.88;
use if $ENV{AUTHOR_TESTING}, 'Test::Warnings';
use Test::DZil;
use Test::Fatal;
use Path::Tiny;
{
package PodCounter;
use Moose;
with 'Dist::Zilla::Role::Plugin',
'Dist::Zilla::Role::ModuleMetadata';
# we do nothing at build time - plugin is poked after the fact
}
my $tzil = Builder->from_config(
{ dist_root => 'does-not-exist' },
{
add_files => {
path(qw(source dist.ini)) => simple_ini(
[ GatherDir => ],
[ MetaConfig => ],
'=PodCounter',
),
path(qw(source lib Foo.pm)) => <<"FOO",
package Foo;
our \$VERSION = '0.001';
=pod
=head1 HELLO
This is pod content.
=cut
FOO
},
},
);
$tzil->chrome->logger->set_debug(1);
is(
exception { $tzil->build },
undef,
'build proceeds normally',
);
my $plugin = $tzil->plugin_named('=PodCounter');
my $pod_content = "\nThis is pod content.\n\n";
# BEGIN TESTS
{
my $mmd = $plugin->module_metadata_for_file($tzil->main_module, collect_pod => 1);
is($mmd->pod('HELLO'), $pod_content, 'MMD object saved pod content');
}
{
my $mmd = $plugin->module_metadata_for_file($tzil->main_module, collect_pod => 0);
is($mmd->pod('HELLO'), $pod_content, 'MMD object collected pod because we reused our cached object');
}
# END TESTS
diag 'got log messages: ', explain $tzil->log_messages
if not Test::Builder->new->is_passing;
done_testing;
|