4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
7 use Module::Build::ConfigData;
9 if ( Module::Build::ConfigData->feature('manpage_support') ) {
12 plan skip_all => 'manpage_support feature is not enabled';
15 #########################
20 my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
23 my $dist = DistGen->new( dir => $tmp );
24 $dist->add_file( 'bin/nopod.pl', <<'---' );
26 print "sample script without pod to test manifypods action\n";
28 $dist->add_file( 'bin/haspod.pl', <<'---' );
36 haspod.pl - sample script with pod to test manifypods action
40 $dist->add_file( 'lib/Simple/NoPod.pm', <<'---' );
41 package Simple::NoPod;
44 $dist->add_file( 'lib/Simple/AllPod.pod', <<'---' );
47 Simple::AllPod - Pure POD
51 Simple Man <simple@example.com>
58 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
60 use File::Spec::Functions qw( catdir );
61 my $destdir = catdir($cwd, 't', 'install_test');
64 my $mb = Module::Build->new(
65 module_name => $dist->name,
66 install_base => $destdir,
67 scripts => [ File::Spec->catfile( 'bin', 'nopod.pl' ),
68 File::Spec->catfile( 'bin', 'haspod.pl' ) ],
70 # need default install paths to ensure manpages & HTML get generated
71 installdirs => 'site',
73 installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
74 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
75 installsitehtml1dir => catdir($tmp, 'site', 'html'),
76 installsitehtml3dir => catdir($tmp, 'site', 'html'),
81 $mb->add_to_cleanup($destdir);
84 is( ref $mb->{properties}->{bindoc_dirs}, 'ARRAY', 'bindoc_dirs' );
85 is( ref $mb->{properties}->{libdoc_dirs}, 'ARRAY', 'libdoc_dirs' );
88 sep => $mb->manpage_separator,
91 ext1 => $mb->config('man1ext'),
92 ext3 => $mb->config('man3ext'),
97 'bin/haspod.pl' => "haspod.pl.$man{ext1}",
98 'lib/Simple.pm' => "Simple.$man{ext3}",
99 'lib/Simple/NoPod.pm' => '',
100 'lib/Simple/AllPod.pod' => "Simple$man{sep}AllPod.$man{ext3}",
103 %distro = map {$mb->localize_file_path($_), $distro{$_}} keys %distro;
105 $mb->dispatch('build');
107 eval {$mb->dispatch('docs')};
110 while (my ($from, $v) = each %distro) {
112 ok ! $mb->contains_pod($from), "$from should not contain POD";
116 my $to = File::Spec->catfile('blib', ($from =~ /^lib/ ? 'libdoc' : 'bindoc'), $v);
117 ok $mb->contains_pod($from), "$from should contain POD";
118 ok -e $to, "Created $to manpage";
122 $mb->dispatch('install');
124 while (my ($from, $v) = each %distro) {
126 my $to = File::Spec->catfile($destdir, 'man', $man{($from =~ /^lib/ ? 'dir3' : 'dir1')}, $v);
127 ok -e $to, "Created $to manpage";
130 $mb->dispatch('realclean');
133 # revert to a pristine state
134 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
136 $dist = DistGen->new( dir => $tmp );
138 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
141 my $mb2 = Module::Build->new(
142 module_name => $dist->name,
143 libdoc_dirs => [qw( foo bar baz )],
146 is( $mb2->{properties}->{libdoc_dirs}->[0], 'foo', 'override libdoc_dirs' );
148 # Make sure we can find our own action documentation
149 ok $mb2->get_action_docs('build');
150 ok !eval{$mb2->get_action_docs('foo')};
152 # Make sure those docs are the correct ones
153 foreach ('testcover', 'disttest') {
154 my $docs = $mb2->get_action_docs($_);
155 like $docs, qr/=item $_/;
156 unlike $docs, qr/\n=/, $docs;
161 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";