6 blib_load('Module::Build');
7 blib_load('Module::Build::ConfigData');
9 if ( Module::Build::ConfigData->feature('manpage_support') ) {
12 plan skip_all => 'manpage_support feature is not enabled';
16 #########################
21 my $tmp = MBTest->tmpdir;
24 my $dist = DistGen->new( dir => $tmp );
25 $dist->add_file( 'bin/nopod.pl', <<'---' );
27 print "sample script without pod to test manifypods action\n";
29 $dist->add_file( 'bin/haspod.pl', <<'---' );
37 haspod.pl - sample script with pod to test manifypods action
41 $dist->add_file( 'lib/Simple/NoPod.pm', <<'---' );
42 package Simple::NoPod;
45 $dist->add_file( 'lib/Simple/AllPod.pod', <<'---' );
48 Simple::AllPod - Pure POD
52 Simple Man <simple@example.com>
61 use File::Spec::Functions qw( catdir );
62 my $destdir = catdir($cwd, 't', 'install_test' . $$);
65 my $mb = Module::Build->new(
66 module_name => $dist->name,
67 install_base => $destdir,
68 scripts => [ File::Spec->catfile( 'bin', 'nopod.pl' ),
69 File::Spec->catfile( 'bin', 'haspod.pl' ) ],
71 # need default install paths to ensure manpages & HTML get generated
72 installdirs => 'site',
74 installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
75 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
76 installsitehtml1dir => catdir($tmp, 'site', 'html'),
77 installsitehtml3dir => catdir($tmp, 'site', 'html'),
82 $mb->add_to_cleanup($destdir);
85 is( ref $mb->{properties}->{bindoc_dirs}, 'ARRAY', 'bindoc_dirs' );
86 is( ref $mb->{properties}->{libdoc_dirs}, 'ARRAY', 'libdoc_dirs' );
89 sep => $mb->manpage_separator,
92 ext1 => $mb->config('man1ext'),
93 ext3 => $mb->config('man3ext'),
98 'bin/haspod.pl' => "haspod.pl.$man{ext1}",
99 'lib/Simple.pm' => "Simple.$man{ext3}",
100 'lib/Simple/NoPod.pm' => '',
101 'lib/Simple/AllPod.pod' => "Simple$man{sep}AllPod.$man{ext3}",
104 %distro = map {$mb->localize_file_path($_), $distro{$_}} keys %distro;
106 my $lib_path = $mb->localize_dir_path('lib');
108 # Remove trailing directory delimiter on VMS for compares
109 $lib_path =~ s/\]// if $^O eq 'VMS';
111 $mb->dispatch('build');
113 eval {$mb->dispatch('docs')};
116 while (my ($from, $v) = each %distro) {
118 ok ! $mb->contains_pod($from), "$from should not contain POD";
122 my $to = File::Spec->catfile('blib', ($from =~ /^[\.\/\[]*lib/ ? 'libdoc' : 'bindoc'), $v);
123 ok $mb->contains_pod($from), "$from should contain POD";
124 ok -e $to, "Created $to manpage";
128 $mb->dispatch('install');
130 while (my ($from, $v) = each %distro) {
132 my $to = File::Spec->catfile
133 ($destdir, 'man', $man{($from =~ /^\Q$lib_path\E/ ? 'dir3' : 'dir1')}, $v);
134 ok -e $to, "Created $to manpage";
137 $mb->dispatch('realclean');
140 # revert to a pristine state
141 $dist->regen( clean => 1 );
143 my $mb2 = Module::Build->new(
144 module_name => $dist->name,
145 libdoc_dirs => [qw( foo bar baz )],
148 is( $mb2->{properties}->{libdoc_dirs}->[0], 'foo', 'override libdoc_dirs' );
150 # Make sure we can find our own action documentation
151 ok $mb2->get_action_docs('build');
152 ok !eval{$mb2->get_action_docs('foo')};
154 # Make sure those docs are the correct ones
155 foreach ('testcover', 'disttest') {
156 my $docs = $mb2->get_action_docs($_);
157 like $docs, qr/=item $_/;
158 unlike $docs, qr/\n=/, $docs;