| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Declare our package |
|
2
|
|
|
|
|
|
|
package Test::Pod::No404s; |
|
3
|
1
|
|
|
1
|
|
2008
|
use strict; use warnings; |
|
|
1
|
|
|
1
|
|
3
|
|
|
|
1
|
|
|
|
|
46
|
|
|
|
1
|
|
|
|
|
6
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
45
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
# Initialize our version |
|
6
|
1
|
|
|
1
|
|
112
|
use vars qw( $VERSION ); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
95
|
|
|
7
|
|
|
|
|
|
|
$VERSION = '0.01'; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Import the modules we need |
|
10
|
1
|
|
|
1
|
|
1606
|
use Pod::Simple::Text; |
|
|
1
|
|
|
|
|
135995
|
|
|
|
1
|
|
|
|
|
40
|
|
|
11
|
1
|
|
|
1
|
|
1776
|
use LWP::UserAgent; |
|
|
1
|
|
|
|
|
174206
|
|
|
|
1
|
|
|
|
|
42
|
|
|
12
|
1
|
|
|
1
|
|
3669
|
use URI::Find; |
|
|
1
|
|
|
|
|
5468
|
|
|
|
1
|
|
|
|
|
78
|
|
|
13
|
|
|
|
|
|
|
require Test::Pod; |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# setup our tests and etc |
|
16
|
1
|
|
|
1
|
|
11
|
use Test::Builder; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
69
|
|
|
17
|
|
|
|
|
|
|
my $Test = Test::Builder->new; |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Thanks to Test::Pod for much of the code here! |
|
20
|
|
|
|
|
|
|
sub import { |
|
21
|
1
|
|
|
1
|
|
13
|
my $self = shift; |
|
22
|
1
|
|
|
|
|
4
|
my $caller = caller; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
|
|
|
|
2
|
for my $func ( qw( pod_file_ok all_pod_files_ok ) ) { |
|
25
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; ## no critic ( ProhibitNoStrict ) |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4172
|
|
|
26
|
2
|
|
|
|
|
6
|
*{$caller."::".$func} = \&$func; |
|
|
2
|
|
|
|
|
14
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
6
|
$Test->exported_to($caller); |
|
30
|
1
|
|
|
|
|
12
|
$Test->plan(@_); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub pod_file_ok { |
|
34
|
0
|
|
|
0
|
1
|
|
my $file = shift; |
|
35
|
0
|
0
|
|
|
|
|
my $name = @_ ? shift : "404 test for $file"; |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
if ( ! -f $file ) { |
|
38
|
0
|
|
|
|
|
|
$Test->ok( 0, $name ); |
|
39
|
0
|
|
|
|
|
|
$Test->diag( "$file does not exist" ); |
|
40
|
0
|
|
|
|
|
|
return; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# Parse the POD! |
|
44
|
0
|
|
|
|
|
|
my $parser = Pod::Simple::Text->new; |
|
45
|
0
|
|
|
|
|
|
my $output; |
|
46
|
0
|
|
|
|
|
|
$parser->output_string( \$output ); |
|
47
|
0
|
|
|
|
|
|
$parser->parse_file( $file ); |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# is POD well-formed? |
|
50
|
0
|
0
|
|
|
|
|
if ( $parser->any_errata_seen ) { |
|
51
|
0
|
|
|
|
|
|
$Test->ok( 0, $name ); |
|
52
|
0
|
|
|
|
|
|
$Test->diag( "Unable to parse POD in $file" ); |
|
53
|
0
|
|
|
|
|
|
return 0; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Did we see POD in the file? |
|
57
|
0
|
0
|
|
|
|
|
if ( $parser->doc_has_started ) { |
|
58
|
0
|
|
|
|
|
|
my @links; |
|
59
|
|
|
|
|
|
|
my $finder = URI::Find->new( sub { |
|
60
|
0
|
|
|
0
|
|
|
my $uri = shift; |
|
61
|
0
|
|
|
|
|
|
my $scheme = $uri->scheme; |
|
62
|
0
|
0
|
0
|
|
|
|
if ( defined $scheme and ( $scheme eq 'http' or $scheme eq 'https' ) ) { |
|
|
|
|
0
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# Make sure we have unique links... |
|
64
|
0
|
0
|
|
|
|
|
if ( ! grep { $_->eq( $uri ) } @links ) { |
|
|
0
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
push @links, $uri; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
0
|
|
|
|
|
|
} ); |
|
69
|
0
|
|
|
|
|
|
$finder->find( \$output ); |
|
70
|
|
|
|
|
|
|
|
|
71
|
0
|
0
|
|
|
|
|
if ( scalar @links ) { |
|
72
|
|
|
|
|
|
|
# Verify the links! |
|
73
|
0
|
|
|
|
|
|
my $ok = 1; |
|
74
|
0
|
|
|
|
|
|
my @errors; |
|
75
|
0
|
|
|
|
|
|
my $ua = LWP::UserAgent->new; |
|
76
|
0
|
|
|
|
|
|
foreach my $l ( @links ) { |
|
77
|
0
|
|
|
|
|
|
my $response = $ua->head( $l ); |
|
78
|
0
|
0
|
|
|
|
|
if ( $response->is_error ) { |
|
79
|
0
|
|
|
|
|
|
$ok = 0; |
|
80
|
0
|
|
|
|
|
|
push( @errors, [ $l->as_string, $response->status_line ] ); |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
0
|
0
|
|
|
|
|
if ( $ok ) { |
|
85
|
0
|
|
|
|
|
|
$Test->ok( 1, $name ); |
|
86
|
|
|
|
|
|
|
} else { |
|
87
|
0
|
|
|
|
|
|
$Test->ok( 0, $name ); |
|
88
|
0
|
|
|
|
|
|
foreach my $e ( @errors ) { |
|
89
|
0
|
|
|
|
|
|
$Test->diag( "Error retrieving '$e->[0]': $e->[1]" ); |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
} |
|
92
|
|
|
|
|
|
|
} else { |
|
93
|
0
|
|
|
|
|
|
$Test->ok( 1, $name ); |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
} else { |
|
96
|
0
|
|
|
|
|
|
$Test->ok( 1, $name ); |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
0
|
|
|
|
|
|
return 1; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub all_pod_files_ok { |
|
103
|
0
|
0
|
|
0
|
1
|
|
my @files = @_ ? @_ : Test::Pod::all_pod_files(); |
|
104
|
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
$Test->plan( tests => scalar @files ); |
|
106
|
|
|
|
|
|
|
|
|
107
|
0
|
|
|
|
|
|
my $ok = 1; |
|
108
|
0
|
|
|
|
|
|
foreach my $file ( @files ) { |
|
109
|
0
|
0
|
|
|
|
|
pod_file_ok( $file ) or undef $ok; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
0
|
|
|
|
|
|
return $ok; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |
|
116
|
|
|
|
|
|
|
__END__ |