From 259f5e0bbc6277b397458cb905d37baaa68aaada Mon Sep 17 00:00:00 2001 From: "Craig A. Berry" Date: Sat, 30 Jan 2016 17:25:05 -0600 Subject: [PATCH] Tweaks to podlators integration. It's only perlpodstyle that we can't build the man page for since it lives in the top-level pod/ directory. Plus there was a new test that I had missed in the integration. --- MANIFEST | 1 + Porting/Maintainers.pl | 2 +- cpan/podlators/Makefile.PL | 5 ++- cpan/podlators/t/man/no-encode.t | 69 ++++++++++++++++++++++++++++++++++++++++ t/porting/customized.dat | 2 +- 5 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 cpan/podlators/t/man/no-encode.t diff --git a/MANIFEST b/MANIFEST index 6ffe6d9..71a2dec 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1897,6 +1897,7 @@ cpan/podlators/t/man/devise-date.t podlators test cpan/podlators/t/man/devise-title.t podlators test cpan/podlators/t/man/empty.t podlators test cpan/podlators/t/man/heading.t podlators test +cpan/podlators/t/man/no-encode.t podlators test cpan/podlators/t/man/options.t podlators test cpan/podlators/t/man/utf8-io.t podlators test cpan/podlators/t/parselink/basic.t podlators test diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index a755090..e82d47c 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -974,7 +974,7 @@ use File::Glob qw(:case); 'MAP' => { '' => 'cpan/podlators/', # this file lives outside the cpan/ directory - 'pod/perlpodstyle.pod' => 'pod/perlpodstyle.pod', + 'pod/perlpodstyle' => 'pod/perlpodstyle.pod', }, 'CUSTOMIZED' => [ qw( Makefile.PL ) diff --git a/cpan/podlators/Makefile.PL b/cpan/podlators/Makefile.PL index 964756c..5092857 100644 --- a/cpan/podlators/Makefile.PL +++ b/cpan/podlators/Makefile.PL @@ -76,7 +76,8 @@ my %metadata = ( MAN1PODS => { man1pod('scripts', 'pod2man'), man1pod('scripts', 'pod2text'), - man1pod('pod', 'perlpodstyle'), + # This one lives in the top-level pod/ directory in core + ($ENV{PERL_CORE} ? () : man1pod('pod', 'perlpodstyle')), }, # Clean some additional files. @@ -129,8 +130,6 @@ for my $key (keys(%supported)) { } } -delete $metadata{MAN1PODS} if $ENV{PERL_CORE}; - # Generate the actual Makefile. Pick an arbitrary module to pull the version # from, since they should all have the same version. WriteMakefile(%metadata); diff --git a/cpan/podlators/t/man/no-encode.t b/cpan/podlators/t/man/no-encode.t new file mode 100644 index 0000000..bdd4e68 --- /dev/null +++ b/cpan/podlators/t/man/no-encode.t @@ -0,0 +1,69 @@ +#!/usr/bin/perl +# +# Test for graceful degradation to non-utf8 output without Encode module. +# +# Copyright 2016 Niko Tyni +# Copyright 2016 Russ Allbery +# +# This program is free software; you may redistribute it and/or modify it +# under the same terms as Perl itself. + +use 5.006; +use strict; +use warnings; + +use Test::More tests => 6; + +# Force the Encode module to be impossible to import. +BEGIN { + ok(!$INC{'Encode.pm'}, 'Encode is not loaded yet'); + my $reject_encode = sub { + if ($_[1] eq 'Encode.pm') { + die "refusing to load Encode\n"; + } + }; + unshift(@INC, $reject_encode); + ok(!eval { require Encode }, 'Cannot load Encode any more'); +} + +# Load the module. +BEGIN { + use_ok('Pod::Man'); +} + +# Ensure we don't get warnings by throwing an exception if we see any. This +# is overridden below when we enable utf8 and do expect a warning. +local $SIG{__WARN__} = sub { die "No warnings expected\n" }; + +# First, check that everything works properly when utf8 isn't set. We expect +# to get accent-mangled ASCII output. Don't use Test::Podlators, since it +# wants to import Encode. +# +## no critic (ValuesAndExpressions::ProhibitEscapedCharacters) +my $pod = "=encoding latin1\n\n=head1 NAME\n\nBeyonc\xE9!"; +my $parser = Pod::Man->new(utf8 => 0, name => 'test'); +my $output; +$parser->output_string(\$output); +$parser->parse_string_document($pod); +like( + $output, + qr{ Beyonce\\[*]\' }xms, + 'Works without Encode for non-utf8 output' +); + +# Now, try with the utf8 option set. We should then get a warning that we're +# falling back to non-utf8 output. +{ + local $SIG{__WARN__} = sub { + like( + $_[0], + qr{ falling [ ] back [ ] to [ ] non-utf8 }xms, + 'Pod::Man warns on utf8 option with no Encode module' + ); + }; + $parser = Pod::Man->new(utf8 => 1, name => 'test'); +} +my $output_fallback; +$parser->output_string(\$output_fallback); +$parser->parse_string_document($pod); +is($output_fallback, $output, 'Degraded gracefully to non-utf8 output'); diff --git a/t/porting/customized.dat b/t/porting/customized.dat index c356bb7..94245ed 100644 --- a/t/porting/customized.dat +++ b/t/porting/customized.dat @@ -55,6 +55,6 @@ Win32API::File cpan/Win32API-File/t/file.t 124e64aa77e755235eb297644a87fac5388d3 Win32API::File cpan/Win32API-File/t/tie.t 712ea7edd0cc805ce1c0b8172c01b03dd19b583d Win32API::File cpan/Win32API-File/typemap 24bff088babeadac0873e8df390d1666d9d9db4a autodie cpan/autodie/t/mkdir.t 9e70d2282a3cc7d76a78bf8144fccba20fb37dac -podlators cpan/podlators/Makefile.PL d99c9f93d4b26ec27400d41227b6bcd155f48ba0 +podlators cpan/podlators/Makefile.PL a356edc61af0185c174407fc5d1edb30e2a42ea6 version cpan/version/lib/version.pm d0923b895d57f1d669ae36fcf85c87b16db341d1 version vutil.c 668f17ca43e2527645674d29ba772b86330d5663 -- 1.8.3.1