]> git.imager.perl.org - imager.git/blobdiff - xt/x50cpod.t
[rt #74875] add unshipped test for unclosed pod in C sources
[imager.git] / xt / x50cpod.t
diff --git a/xt/x50cpod.t b/xt/x50cpod.t
new file mode 100644 (file)
index 0000000..245eb82
--- /dev/null
@@ -0,0 +1,43 @@
+#!perl -w
+use strict;
+use Test::More;
+use ExtUtils::Manifest qw(maniread);
+
+# RT #74875
+my $manifest = maniread();
+my @files = grep /\.(c|im|h)$/, sort keys %$manifest;
+plan tests => scalar @files;
+
+++$|;
+for my $file (@files) {
+  my $ok = 1;
+  if (open my $fh, "<", $file) {
+    my $in_pod;
+    while (<$fh>) {
+      if (/^=cut/) {
+       if ($in_pod) {
+         $in_pod = 0;
+       }
+       else {
+         diag("$file:$.: found =cut without pod");
+         $ok = 0;
+       }
+      }
+      elsif (/^=\w+/) {
+       $in_pod = $.;
+      }
+      elsif (m(\*/)) {
+       if ($in_pod) {
+         diag("$file:$.: unclosed pod starting $in_pod");
+         $ok = 0;
+       }
+      }
+    }
+    close $fh;
+  }
+  else {
+    diag("Cannot open $file: $!");
+    $ok = 0;
+  }
+  ok($ok, $file);
+}