#!/usr/bin/perl -w
local
$SIG
{__WARN__} =
sub
{};
BEGIN {
eval
{
};
if
($@) {
print
"1..0 # Skipped - do not have Find::File::Rule or Pod::Checker installed\n"
;
exit
;
}
}
BEGIN {
@files
= File::Find::Rule->file()->name(
'*.pm'
,
'*.pod'
)->in(
'.'
);
}
foreach
my
$file
(
@files
) {
my
$hash
= _check_pod(
$file
);
my
$status
=
$hash
->{result};
if
(
$status
== NO_FILE ) {
ok( 0,
"Did not find [$file]"
);
}
elsif
(
$status
== OK ) {
ok( 1,
"Pod OK in [$file]"
);
}
elsif
(
$status
== ERRORS ) {
ok( 0,
"Pod had errors in [$file]"
);
system
(
"podchecker"
,
$file
);
}
elsif
(
$status
== WARNINGS ) {
ok( 1,
"Pod had warnings in [$file], but that's okay"
);
}
elsif
(
$status
== WARNINGS ) {
ok( 0,
"Pod had warnings in [$file]"
);
}
elsif
(
$status
== NO_POD ) {
ok( 0,
"Found no pod in [$file]"
);
}
else
{
ok( 0,
"Mysterious failure for [$file]"
);
}
}
sub
_check_pod {
my
$file
=
shift
;
return
{
result
=> NO_FILE }
unless
-e
$file
;
my
%hash
= ();
my
$checker
= Pod::Checker->new();
tie
(
*NULL
,
'IO::Null'
);
$checker
->parse_from_file(
$file
, \
*NULL
);
$hash
{ result } =
do
{
$hash
{errors} =
$checker
->num_errors;
$hash
{warnings} =
$checker
->can(
'num_warnings'
) ?
$checker
->num_warnings : 0;
if
(
$hash
{errors} == -1 ) {
NO_POD;
}
elsif
(
$hash
{errors} > 0 ) {
ERRORS;
}
elsif
(
$hash
{warnings} > 0 ) {
WARNINGS;
}
else
{
OK;
}
};
return
\
%hash
;
}