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';
14 ensure_blib('Module::Build');
17 #########################
22 my $tmp = MBTest->tmpdir;
25 my $dist = DistGen->new( dir => $tmp );
26 $dist->add_file( 'bin/nopod.pl', <<'---' );
28 print "sample script without pod to test manifypods action\n";
30 $dist->add_file( 'bin/haspod.pl', <<'---' );
38 haspod.pl - sample script with pod to test manifypods action
42 $dist->add_file( 'lib/Simple/NoPod.pm', <<'---' );
43 package Simple::NoPod;
46 $dist->add_file( 'lib/Simple/AllPod.pod', <<'---' );
49 Simple::AllPod - Pure POD
53 Simple Man <simple@example.com>
62 use File::Spec::Functions qw( catdir );
63 my $destdir = catdir($cwd, 't', 'install_test' . $$);
66 my $mb = Module::Build->new(
67 module_name => $dist->name,
68 install_base => $destdir,
69 scripts => [ File::Spec->catfile( 'bin', 'nopod.pl' ),
70 File::Spec->catfile( 'bin', 'haspod.pl' ) ],
72 # need default install paths to ensure manpages & HTML get generated
73 installdirs => 'site',
75 installsiteman1dir => catdir($tmp, 'site', 'man', 'man1'),
76 installsiteman3dir => catdir($tmp, 'site', 'man', 'man3'),
77 installsitehtml1dir => catdir($tmp, 'site', 'html'),
78 installsitehtml3dir => catdir($tmp, 'site', 'html'),
83 $mb->add_to_cleanup($destdir);
86 is( ref $mb->{properties}->{bindoc_dirs}, 'ARRAY', 'bindoc_dirs' );
87 is( ref $mb->{properties}->{libdoc_dirs}, 'ARRAY', 'libdoc_dirs' );
90 sep => $mb->manpage_separator,
93 ext1 => $mb->config('man1ext'),
94 ext3 => $mb->config('man3ext'),
99 'bin/haspod.pl' => "haspod.pl.$man{ext1}",
100 'lib/Simple.pm' => "Simple.$man{ext3}",
101 'lib/Simple/NoPod.pm' => '',
102 'lib/Simple/AllPod.pod' => "Simple$man{sep}AllPod.$man{ext3}",
105 %distro = map {$mb->localize_file_path($_), $distro{$_}} keys %distro;
107 my $lib_path = $mb->localize_dir_path('lib');
109 # Remove trailing directory delimiter on VMS for compares
110 $lib_path =~ s/\]// if $^O eq 'VMS';
112 $mb->dispatch('build');
114 eval {$mb->dispatch('docs')};
117 while (my ($from, $v) = each %distro) {
119 ok ! $mb->contains_pod($from), "$from should not contain POD";
123 my $to = File::Spec->catfile('blib', ($from =~ /^[\.\/\[]*lib/ ? 'libdoc' : 'bindoc'), $v);
124 ok $mb->contains_pod($from), "$from should contain POD";
125 ok -e $to, "Created $to manpage";
129 $mb->dispatch('install');
131 while (my ($from, $v) = each %distro) {
133 my $to = File::Spec->catfile
134 ($destdir, 'man', $man{($from =~ /^\Q$lib_path\E/ ? 'dir3' : 'dir1')}, $v);
135 ok -e $to, "Created $to manpage";
138 $mb->dispatch('realclean');
141 # revert to a pristine state
143 $dist = DistGen->new( dir => $tmp );
148 my $mb2 = Module::Build->new(
149 module_name => $dist->name,
150 libdoc_dirs => [qw( foo bar baz )],
153 is( $mb2->{properties}->{libdoc_dirs}->[0], 'foo', 'override libdoc_dirs' );
155 # Make sure we can find our own action documentation
156 ok $mb2->get_action_docs('build');
157 ok !eval{$mb2->get_action_docs('foo')};
159 # Make sure those docs are the correct ones
160 foreach ('testcover', 'disttest') {
161 my $docs = $mb2->get_action_docs($_);
162 like $docs, qr/=item $_/;
163 unlike $docs, qr/\n=/, $docs;