Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/ExtUtils/Command/MM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ sub pod2man {

next if ((-e $man) &&
(mtime($man) > mtime($pod)) &&
(mtime($man) > mtime("Makefile")));
(mtime($man) > (mtime("Makefile") // 0)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's appropriate to make EUMM require 5.10 for a trivial line.


my $parser = Pod::Man->new(%options);
$parser->parse_from_file($pod, $man)
Expand Down
46 changes: 45 additions & 1 deletion t/pod2man.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ use lib 't/lib';

use ExtUtils::Command::MM;

use Test::More tests => 3;
use File::Temp qw(tempdir);
use File::Spec;
use Cwd qw(getcwd);

use Test::More tests => 4;

# The argument to perm_rw was optional.
# [rt.cpan.org 35190]
Expand All @@ -24,6 +28,46 @@ use Test::More tests => 3;
};


# No "uninitialized value" warnings when Makefile does not exist (GH #479).
# When the man page is up-to-date relative to the pod source, pod2man skips
# regeneration by comparing mtimes. The third comparison is against
# "Makefile" (or the configured FIRST_MAKEFILE). If that file does not exist,
# mtime() returns undef and Perl emits an uninitialized-value warning.
{
my $cwd = getcwd();
my $tmpdir = tempdir(CLEANUP => 1);
chdir $tmpdir or die "chdir $tmpdir: $!";

# Create a simple pod source file.
open my $fh, '>', 'foo.pod' or die $!;
print $fh "=head1 NAME\n\nfoo - test\n\n=cut\n";
close $fh;

# Create a man page with a future mtime so it appears up-to-date.
open $fh, '>', 'foo.1' or die $!;
print $fh "man page\n";
close $fh;

my $future = time() + 3600;
utime $future, $future, 'foo.1';

# Ensure there is no Makefile in this directory.
die "Unexpected Makefile in tmpdir" if -e 'Makefile';

my @warnings;
local $SIG{__WARN__} = sub { push @warnings, @_ };

local @ARGV = ('foo.pod', 'foo.1');
pod2man();

chdir $cwd or die "chdir $cwd: $!";

my @uninit = grep { /uninitialized/ } @warnings;
is scalar(@uninit), 0,
'no uninitialized-value warnings when Makefile is absent (GH #479)';
}


# Simulate the failure of Pod::Man loading.
# pod2man() should react gracefully.
{
Expand Down