Remove unused Module::Build tests
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / manifypods.t
CommitLineData
bb4e9162 1#!/usr/bin/perl -w
2
3use strict;
4use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5use MBTest;
6use Module::Build;
7use Module::Build::ConfigData;
8
9if ( Module::Build::ConfigData->feature('manpage_support') ) {
10 plan tests => 21;
11} else {
12 plan skip_all => 'manpage_support feature is not enabled';
13}
14
15#########################
16
17
18use Cwd ();
19my $cwd = Cwd::cwd;
20my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
21
22use DistGen;
23my $dist = DistGen->new( dir => $tmp );
24$dist->add_file( 'bin/nopod.pl', <<'---' );
25#!perl -w
26print "sample script without pod to test manifypods action\n";
27---
28$dist->add_file( 'bin/haspod.pl', <<'---' );
29#!perl -w
30print "Hello, world";
31
32__END__
33
34=head1 NAME
35
36haspod.pl - sample script with pod to test manifypods action
37
38=cut
39---
40$dist->add_file( 'lib/Simple/NoPod.pm', <<'---' );
41package Simple::NoPod;
421;
43---
44$dist->add_file( 'lib/Simple/AllPod.pod', <<'---' );
45=head1 NAME
46
47Simple::AllPod - Pure POD
48
49=head1 AUTHOR
50
51Simple Man <simple@example.com>
52
53=cut
54---
55$dist->regen;
56
57
58chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
59
60use File::Spec::Functions qw( catdir );
61my $destdir = catdir($cwd, 't', 'install_test');
62
63
64my $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' ) ],
69
70 # need default install paths to ensure manpages & HTML get generated
71 installdirs => 'site',
72 config => {
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'),
77 }
78
79);
80
81$mb->add_to_cleanup($destdir);
82
83
84is( ref $mb->{properties}->{bindoc_dirs}, 'ARRAY', 'bindoc_dirs' );
85is( ref $mb->{properties}->{libdoc_dirs}, 'ARRAY', 'libdoc_dirs' );
86
87my %man = (
88 sep => $mb->manpage_separator,
89 dir1 => 'man1',
90 dir3 => 'man3',
91 ext1 => $mb->config('man1ext'),
92 ext3 => $mb->config('man3ext'),
93 );
94
95my %distro = (
96 'bin/nopod.pl' => '',
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}",
101 );
102
103%distro = map {$mb->localize_file_path($_), $distro{$_}} keys %distro;
104
105$mb->dispatch('build');
106
107eval {$mb->dispatch('docs')};
108is $@, '';
109
110while (my ($from, $v) = each %distro) {
111 if (!$v) {
112 ok ! $mb->contains_pod($from), "$from should not contain POD";
113 next;
114 }
115
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";
119}
120
121
122$mb->dispatch('install');
123
124while (my ($from, $v) = each %distro) {
125 next unless $v;
126 my $to = File::Spec->catfile($destdir, 'man', $man{($from =~ /^lib/ ? 'dir3' : 'dir1')}, $v);
127 ok -e $to, "Created $to manpage";
128}
129
130$mb->dispatch('realclean');
131
132
133# revert to a pristine state
134chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
135$dist->remove;
136$dist = DistGen->new( dir => $tmp );
137$dist->regen;
138chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
139
140
141my $mb2 = Module::Build->new(
142 module_name => $dist->name,
143 libdoc_dirs => [qw( foo bar baz )],
144);
145
146is( $mb2->{properties}->{libdoc_dirs}->[0], 'foo', 'override libdoc_dirs' );
147
148# Make sure we can find our own action documentation
149ok $mb2->get_action_docs('build');
7253302f 150ok !eval{$mb2->get_action_docs('foo')};
bb4e9162 151
152# Make sure those docs are the correct ones
153foreach ('testcover', 'disttest') {
154 my $docs = $mb2->get_action_docs($_);
155 like $docs, qr/=item $_/;
156 unlike $docs, qr/\n=/, $docs;
157}
158
159
160# cleanup
161chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
162$dist->remove;
163
164use File::Path;
165rmtree( $tmp );