This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
3b6e352d3a689aa275372d5e38139794d4b5e212
[perl5.git] / cpan / Pod-Checker / t / pod / selfcheck.t
1 #!/usr/bin/perl\r
2 use File::Basename;\r
3 use File::Spec;\r
4 use strict;\r
5 my $THISDIR;\r
6 BEGIN {\r
7    $THISDIR = dirname $0;\r
8    unshift @INC, $THISDIR;\r
9    require "testpchk.pl";\r
10    import TestPodChecker qw(testpodcheck);\r
11 }\r
12 \r
13 # test that our POD is correct!\r
14 my $path = File::Spec->catfile($THISDIR,(File::Spec->updir()) x 2, 'lib', 'Pod', '*.pm');\r
15 print "THISDIR=$THISDIR PATH=$path\n";\r
16 my @pods = glob($path);\r
17 print "PODS=@pods\n";\r
18 \r
19 print "1..",scalar(@pods),"\n";\r
20 \r
21 my $errs = 0;\r
22 my $testnum = 1;\r
23 foreach my $pod (@pods) {\r
24   my $out = File::Spec->catfile($THISDIR, basename($pod));\r
25   $out =~ s{\.pm}{.OUT};\r
26   my %options = ( -Out => $out );\r
27   my $failmsg = testpodcheck(-In => $pod, -Out => $out, -Cmp => "$THISDIR/empty.xr");\r
28   if($failmsg) {\r
29     if(open(IN, "<$out")) {\r
30       while(<IN>) {\r
31         warn "podchecker: $_";\r
32       }\r
33       close(IN);\r
34     } else {\r
35       warn "Error: Cannot read output file $out: $!\n";\r
36     }\r
37     print "not ok $testnum\n";\r
38     $errs++;\r
39   } else {\r
40     print "ok $testnum\n";\r
41   }\r
42   $testnum++;\r
43 }\r
44 exit( ($errs == 0) ? 0 : -1 )  unless $ENV{HARNESS_ACTIVE};\r
45 \r