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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
|
#!/usr/bin/perl -w
# Test if MakeMaker declines to build man pages under the right conditions.
BEGIN {
unshift @INC, 't/lib';
}
use strict;
use Test::More tests => 50;
use File::Spec;
use File::Temp qw[tempdir];
use TieOut;
use MakeMaker::Test::Utils;
use MakeMaker::Test::Setup::BFD;
use ExtUtils::MakeMaker;
use ExtUtils::MakeMaker::Config;
# Simulate an installation which has man page generation turned off to
# ensure these tests will still work.
$Config{installman3dir} = 'none';
chdir 't';
perl_lib; # sets $ENV{PERL5LIB} relative to t/
my $tmpdir = tempdir( DIR => '../t', CLEANUP => 1 );
use Cwd; my $cwd = getcwd; END { chdir $cwd } # so File::Temp can cleanup
chdir $tmpdir;
ok( setup_recurs(), 'setup' );
END {
ok chdir File::Spec->updir, 'chdir updir';
ok teardown_recurs(), 'teardown';
}
ok( chdir 'Big-Dummy', "chdir'd to Big-Dummy" ) ||
diag("chdir failed: $!");
my $README = 'README.pod';
{ open my $fh, '>', $README or die "$README: $!"; }
ok((my $stdout = tie *STDOUT, 'TieOut'), 'tie stdout');
{
local $Config{installman3dir} = File::Spec->catdir(qw(t lib));
my $mm;
{
# suppress noisy & unnecessary "WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod..."
my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, shift; };
$mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
);
# verify that suppressed warnings are present
isnt (scalar(@warnings), 0);
if (scalar(@warnings)) {
note (sprintf('suppressed warnings: [ "%s" ]', do { my $s = join(q/" , "/, @warnings); $s =~ s/([^[:print:]])/sprintf('\x{%x}', ord($1))/egmsx; $s; }));
}
}
my %got = %{ $mm->{MAN3PODS} };
# because value too OS-specific
my $delete_key = $^O eq 'VMS' ? '[.lib.Big]Dummy.pm' : 'lib/Big/Dummy.pm';
ok delete($got{$delete_key}), 'normal man3pod';
is_deeply \%got, {}, 'no extra man3pod';
}
{
my $mm;
{
# suppress noisy & unnecessary "WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod..."
my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, shift; };
$mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
INSTALLMAN3DIR => 'none'
);
# verify that suppressed warnings are present
isnt (scalar(@warnings), 0);
if (scalar(@warnings)) {
note (sprintf('suppressed warnings: [ "%s" ]', do { my $s = join(q/" , "/, @warnings); $s =~ s/([^[:print:]])/sprintf('\x{%x}', ord($1))/egmsx; $s; }));
}
}
is_deeply $mm->{MAN3PODS}, {}, 'suppress man3pod with "none"';
}
{
my $mm;
{
# suppress noisy & unnecessary "WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod..."
my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, shift; };
$mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
MAN3PODS => {}
);
# verify that suppressed warnings are present
isnt (scalar(@warnings), 0);
if (scalar(@warnings)) {
note (sprintf('suppressed warnings: [ "%s" ]', do { my $s = join(q/" , "/, @warnings); $s =~ s/([^[:print:]])/sprintf('\x{%x}', ord($1))/egmsx; $s; }));
}
}
is_deeply $mm->{MAN3PODS}, {}, 'suppress man3pod with {}';
}
{
my $mm;
{
# suppress noisy & unnecessary "WARNING: Older versions of ExtUtils::MakeMaker may errantly install README.pod..."
my @warnings = ();
local $SIG{__WARN__} = sub { push @warnings, shift; };
$mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
MAN3PODS => { "Foo.pm" => "Foo.1" }
);
# verify that suppressed warnings are present
isnt (scalar(@warnings), 0);
if (scalar(@warnings)) {
note (sprintf('suppressed warnings: [ "%s" ]', do { my $s = join(q/" , "/, @warnings); $s =~ s/([^[:print:]])/sprintf('\x{%x}', ord($1))/egmsx; $s; }));
}
}
is_deeply $mm->{MAN3PODS}, { "Foo.pm" => "Foo.1" }, 'override man3pod';
}
unlink $README;
# Check that we find the manage section from the directory
{
local $Config{installman1dir} = '';
local $Config{installman3dir} = '';
local $Config{installsiteman1dir} = '';
local $Config{installsiteman3dir} = '';
local $Config{installvendorman1dir} = '';
local $Config{installvendorman3dir} = '';
local $Config{usevendorprefix} = '';
local $Config{vendorprefixexp} = '';
my $INSTALLDIRS = 'site';
my $sections_ok = sub {
my ( $man1section, $man3section, $m ) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
INSTALLDIRS => $INSTALLDIRS,
);
is( $mm->{MAN1SECTION}, $man1section,
"$m man1section is $man1section" );
is( $mm->{MAN3SECTION}, $man3section,
"$m man3section is $man3section" );
};
# Correctly detect known man sections
foreach my $s ( '{num}', '{num}p', '{num}pm', qw< l n o C L >, "L{num}", )
{
( my $man1section = $s ) =~ s/\{num\}/1/;
( my $man3section = $s ) =~ s/\{num\}/3/;
$Config{installman1dir}
= File::Spec->catdir( 'foo', "man$man1section" );
$Config{installman3dir}
= File::Spec->catdir( 'foo', "man$man3section" );
$sections_ok->( $man1section, $man3section, "From main [$s]" );
}
# Ignore unknown man sections
foreach my $s ( '', qw< 2 2p 33 >, "C{num}" ) {
( my $man1section = $s ) =~ s/\{num\}/1/;
( my $man3section = $s ) =~ s/\{num\}/3/;
$Config{installman1dir}
= File::Spec->catdir( 'foo', "man$man1section" );
$Config{installman3dir}
= File::Spec->catdir( 'foo', "man$man3section" );
$sections_ok->( 1, 3, "Ignore unrecognized [$s]" );
}
# Look in the right installman?dir based on INSTALLDIRS
{
$Config{installman1dir} = File::Spec->catdir( 'foo', 'cat1p' );
$Config{installman3dir} = File::Spec->catdir( 'foo', 'cat3p' );
$Config{installsiteman1dir} = File::Spec->catdir( 'foo', 'catL' );
$Config{installsiteman3dir} = File::Spec->catdir( 'foo', 'catL3' );
$sections_ok->( 'L', 'L3', "From site" );
my $installwas = $INSTALLDIRS;
$INSTALLDIRS = 'perl';
$sections_ok->( '1p', '3p', "From main" );
$INSTALLDIRS = $installwas;
}
# Set MAN?SECTION in Makefile
{
$Config{installman1dir} = File::Spec->catdir( 'foo', 'man1pm' );
$Config{installman3dir} = File::Spec->catdir( 'foo', 'man3pm' );
$Config{installsiteman1dir} = '';
$Config{installsiteman3dir} = '';
my $stdout = tie *STDOUT, 'TieOut' or die;
my $mm = WriteMakefile(
NAME => 'Big::Dummy',
VERSION_FROM => 'lib/Big/Dummy.pm',
MAN1PODS => { foo => 'foo.1' },
INSTALLDIRS => $INSTALLDIRS,
);
my $makefile = slurp($mm->{MAKEFILE});
like $makefile, qr/\QMAN1SECTION = 1pm\E/xms, "Set MAN1SECTION";
like $makefile, qr/\QMAN3SECTION = 3pm\E/xms, "Set MAN3SECTION";
like $makefile, qr/\Q$(POD2MAN) --section=$(MAN1EXT) \E/,
"Set POD2MAN section to \$(MAN1EXT)";
like $makefile, qr/\Q$(POD2MAN) --section=$(MAN3EXT) \E/,
"Set POD2MAN section to \$(MAN3EXT)";
}
}
|