summaryrefslogtreecommitdiff
path: root/cpan/Pod-Parser/t/pod/selfcheck.t
blob: 17df68e301a0fd2ea9a4742d02208f2867cbb8a2 (plain)
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
#!/usr/bin/perl
use Test::More;
use File::Basename;
use File::Spec;
use strict;
my $THISDIR;
BEGIN {
   $THISDIR = dirname $0;
   unshift @INC, $THISDIR;
   eval {
     require "testpchk.pl";
     import TestPodChecker qw(testpodcheck);
   };
   warn $@ if $@;
};

my @pods;
unless($Pod::Checker::VERSION && $Pod::Checker::VERSION > 1.40) {
  plan skip_all => "we do not have a good Pod::Checker around";
} else {
  my $path = File::Spec->catfile($THISDIR,(File::Spec->updir()) x 2, 'lib', 'Pod', '*.pm');
  print "THISDIR=$THISDIR PATH=$path\n";
  @pods = glob($path);
  print "PODS=@pods\n";
  plan tests => scalar(@pods);
}

# test that our POD is correct!
my $errs = 0;

foreach my $pod (@pods) {
  my $out = File::Spec->catfile($THISDIR, basename($pod));
  $out =~ s{\.pm}{.OUT};
  my %options = ( -Out => $out );
  my $failmsg = testpodcheck(-In => $pod, -Out => $out, -Cmp => "$THISDIR/empty.xr");
  if($failmsg) {
    if(open(IN, "<$out")) {
      while(<IN>) {
        warn "podchecker: $_";
      }
      close(IN);
    } else {
      warn "Error: Cannot read output file $out: $!\n";
    }
    ok(0, $pod);
    $errs++;
  } else {
    ok(1, $pod);
  }
}

exit( ($errs == 0) ? 0 : -1 )  unless $ENV{HARNESS_ACTIVE};