This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
podcheck.t: Ignore perldelta_template.pod
[perl5.git] / t / porting / podcheck.t
index 2a7c87b..b1022e1 100644 (file)
@@ -550,17 +550,23 @@ package My::Pod::Checker {      # Extend Pod::Checker
 
         $self->SUPER::verbatim($paragraph, $line_num, $pod_para);
 
+        my $addr = Scalar::Util::refaddr $self;
+
         # Pick up the name, since the parent class doesn't in verbatim
         # NAMEs; so treat as non-verbatim.  The parent class only allows one
         # paragraph in a NAME section, so if there is an extra blank line, it
         # will trigger a message, but such a blank line is harmless, so skip
         # in that case.
-        if ($in_NAME{Scalar::Util::refaddr $self} && $paragraph =~ /\S/) {
+        if ($in_NAME{$addr} && $paragraph =~ /\S/) {
             $self->textblock($paragraph, $line_num, $pod_para);
         }
 
         my @lines = split /^/, $paragraph;
         for my $i (0 .. @lines - 1) {
+            if ( my $encoding = $seen_encoding_cmd{$addr} ) {
+              require Encode;
+              $lines[$i] = Encode::decode($encoding, $lines[$i]);
+            }
             $lines[$i] =~ s/\s+$//;
             my $indent = $self->get_current_indent;
             my $exceeds = length(Text::Tabs::expand($lines[$i]))
@@ -638,7 +644,7 @@ package My::Pod::Checker {      # Extend Pod::Checker
         }
         elsif ($cmd eq "encoding") {
             my ($file, $line) = $pod_para->file_line;
-            $seen_encoding_cmd{$addr} = 1;
+            $seen_encoding_cmd{$addr} = $paragraph; # for later decoding
             if ($command_count{$addr} != 1 && $seen_pod_cmd{$addr}) {
                 $self->poderror({ -line => $line, -file => $file,
                                   -msg => $encoding_first
@@ -848,8 +854,8 @@ my %excluded_files = (
 
 # Convert to more generic form.
 foreach my $file (keys %excluded_files) {
-    $excluded_files{canonicalize($excluded_files{$file})}
-                                                    = $excluded_files{$file};
+    delete $excluded_files{$file};
+    $excluded_files{canonicalize($file)} = 1;
 }
 
 # re to match files that are to be parsed only if there is an internal link
@@ -926,7 +932,9 @@ sub extract_pod {   # Extracts just the pod from a file
     open my $in_fh, '<:bytes', $filename
 
         # The file should already have been opened once to get here, so if
-        # fails, just die.
+        # fails, just die.  It's possible that a transitory file containing a
+        # pod would get here, but not bothering to add code for that very
+        # unlikely event.
         or die "Can't open '$filename': $!\n";
 
     my $parser = Pod::Parser->new();
@@ -965,11 +973,14 @@ sub is_pod_file {
         my $candidate;
         if (! open $candidate, '<:bytes', $_) {
 
-            # If it is a broken symbolic link, just skip the file, as it
-            # is probably just a build problem; certainly not a file that
-            # we would want to check the pod of.  Otherwise fail it here
-            # and no reason to process it further.
-            ok(0, "Can't open '$filename': $!") if ! -l $filename;
+            # If a transitory file was found earlier, the open could fail
+            # legitimately and we just skip the file; also skip it if it is a
+            # broken symbolic link, as it is probably just a build problem;
+            # certainly not a file that we would want to check the pod of.
+            # Otherwise fail it here and no reason to process it further.
+            # (But the test count will be off too)
+            ok(0, "Can't open '$filename': $!")
+                                            if -e $filename && ! -l $filename;
             return;
         }
         <$candidate>;