line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::cpanreports; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Created on: 2015-03-01 11:33:26 |
4
|
|
|
|
|
|
|
# Create by: Ivan Wills |
5
|
|
|
|
|
|
|
# $Id$ |
6
|
|
|
|
|
|
|
# $Revision$, $HeadURL$, $Date$ |
7
|
|
|
|
|
|
|
# $Revision$, $Source$, $Date$ |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
751
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
10
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
11
|
1
|
|
|
1
|
|
826
|
use Getopt::Long; |
|
1
|
|
|
|
|
25092
|
|
|
1
|
|
|
|
|
5
|
|
12
|
1
|
|
|
1
|
|
1055
|
use Pod::Usage; |
|
1
|
|
|
|
|
52818
|
|
|
1
|
|
|
|
|
154
|
|
13
|
1
|
|
|
1
|
|
769
|
use Data::Dumper qw/Dumper/; |
|
1
|
|
|
|
|
5436
|
|
|
1
|
|
|
|
|
81
|
|
14
|
1
|
|
|
1
|
|
792
|
use English qw/ -no_match_vars /; |
|
1
|
|
|
|
|
1793
|
|
|
1
|
|
|
|
|
8
|
|
15
|
1
|
|
|
1
|
|
494
|
use base qw/Exporter/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
179
|
|
16
|
1
|
|
|
1
|
|
9
|
use FindBin qw/$Bin/; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
138
|
|
17
|
1
|
|
|
1
|
|
894
|
use YAML::XS qw/Load LoadFile/; |
|
1
|
|
|
|
|
3032
|
|
|
1
|
|
|
|
|
60
|
|
18
|
1
|
|
|
1
|
|
668
|
use HTML::Entities; |
|
1
|
|
|
|
|
4670
|
|
|
1
|
|
|
|
|
85
|
|
19
|
1
|
|
|
1
|
|
45682
|
use WWW::Mechanize; |
|
1
|
|
|
|
|
234625
|
|
|
1
|
|
|
|
|
65
|
|
20
|
1
|
|
|
1
|
|
1202
|
use Path::Tiny; |
|
1
|
|
|
|
|
27742
|
|
|
1
|
|
|
|
|
1933
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = 0.004; |
23
|
|
|
|
|
|
|
my ($name) = $PROGRAM_NAME =~ m{^.*/(.*?)$}mxs; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
my %option = ( |
26
|
|
|
|
|
|
|
version => meta()->{version}, |
27
|
|
|
|
|
|
|
distname => meta()->{name}, |
28
|
|
|
|
|
|
|
dir => 't/report', |
29
|
|
|
|
|
|
|
verbose => 0, |
30
|
|
|
|
|
|
|
man => 0, |
31
|
|
|
|
|
|
|
help => 0, |
32
|
|
|
|
|
|
|
VERSION => 0, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub run { |
37
|
0
|
|
|
0
|
1
|
0
|
my ($self) = @_; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
0
|
Getopt::Long::Configure('bundling'); |
40
|
0
|
0
|
|
|
|
0
|
GetOptions( |
41
|
|
|
|
|
|
|
\%option, |
42
|
|
|
|
|
|
|
'version|v=s', |
43
|
|
|
|
|
|
|
'distiname|d=s', |
44
|
|
|
|
|
|
|
'dir|D=s', |
45
|
|
|
|
|
|
|
'state|s=s', |
46
|
|
|
|
|
|
|
'verbose|V+', |
47
|
|
|
|
|
|
|
'man', |
48
|
|
|
|
|
|
|
'help', |
49
|
|
|
|
|
|
|
'VERSION!', |
50
|
|
|
|
|
|
|
) or pod2usage(2); |
51
|
|
|
|
|
|
|
|
52
|
0
|
0
|
0
|
|
|
0
|
if ( $option{'VERSION'} ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
53
|
0
|
|
|
|
|
0
|
print "$name Version = $VERSION\n"; |
54
|
0
|
|
|
|
|
0
|
exit 1; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
elsif ( $option{'man'} ) { |
57
|
0
|
|
|
|
|
0
|
pod2usage( -verbose => 2 ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
elsif ( $option{'help'} ) { |
60
|
0
|
|
|
|
|
0
|
pod2usage( -verbose => 1 ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ( !$option{version} || !$option{distname} ) { |
63
|
0
|
|
|
|
|
0
|
warn <<'HELP'; |
64
|
|
|
|
|
|
|
The arguments --version and --distname must be specified if you are not |
65
|
|
|
|
|
|
|
running from this script from the distribution's directory. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
HELP |
68
|
0
|
|
|
|
|
0
|
pod2usage( -verbose => 1 ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# do stuff here |
72
|
0
|
|
|
|
|
0
|
my $mech = WWW::Mechanize->new; |
73
|
0
|
|
|
|
|
0
|
my $dir = "$option{dir}/$option{version}"; |
74
|
0
|
|
|
|
|
0
|
my $test_reports = $self->get_report_summary($mech, $dir, $option{distname}, $option{version}); |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
for my $report (@$test_reports) { |
77
|
0
|
0
|
|
|
|
0
|
next if $report->{version} ne $option{version}; |
78
|
0
|
0
|
0
|
|
|
0
|
next if $option{state} && $report->{state} eq $option{state}; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
my $guid = $report->{guid}; |
81
|
0
|
0
|
|
|
|
0
|
next if glob "$dir/*.$guid"; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
0
|
my $file_name = "$dir/log.test-$report->{osname}.$report->{osvers}-$report->{perl}"; |
84
|
0
|
|
|
|
|
0
|
$mech->get("http://www.cpantesters.org/cpan/report/$guid"); |
85
|
0
|
|
|
|
|
0
|
my $text = $mech->content; |
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
|
|
|
0
|
if ($text =~ /ccflags[^\n]+ -DDEBUGGING.+?\n/sm) { |
88
|
0
|
|
|
|
|
0
|
$file_name .= 'd'; |
89
|
|
|
|
|
|
|
} |
90
|
0
|
0
|
|
|
|
0
|
if ($report->{platform} !~ /thread/) { |
91
|
0
|
|
|
|
|
0
|
$file_name .= "-nt"; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
# add the GUID to the file to make determining if the report has been |
95
|
|
|
|
|
|
|
# previously downloaded easy. |
96
|
0
|
|
|
|
|
0
|
$file_name .= ".$guid"; |
97
|
|
|
|
|
|
|
|
98
|
0
|
|
|
|
|
0
|
$text =~ s/^.*\nFrom:/From/sm; |
99
|
0
|
|
|
|
|
0
|
$text =~ s{ .*$}{}s; |
100
|
0
|
|
|
|
|
0
|
decode_entities($text); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
path($file_name)->spew_utf8($text); |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
0
|
return; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
my $meta; |
109
|
|
|
|
|
|
|
sub meta { |
110
|
2
|
100
|
|
2
|
1
|
15
|
return $meta if $meta; |
111
|
1
|
0
|
|
|
|
23
|
my $file |
|
|
50
|
|
|
|
|
|
112
|
|
|
|
|
|
|
= -f 'MYMETA.yml' ? path('MYMETA.yml') |
113
|
|
|
|
|
|
|
: -f '.build/latest/MYMETA.yml' ? path('.build/latest/MYMETA.yml') |
114
|
|
|
|
|
|
|
: path('META.yml'); |
115
|
|
|
|
|
|
|
|
116
|
1
|
|
50
|
|
|
51
|
$meta = eval { LoadFile $file } || {}; |
117
|
1
|
|
|
|
|
361
|
return $meta; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
sub get_report_summary { |
121
|
0
|
|
|
0
|
1
|
|
my ($self, $mech, $dir, $distname, $version) = @_; |
122
|
0
|
|
|
|
|
|
my $cache = path("$dir/$distname.yml"); |
123
|
0
|
|
|
|
|
|
$cache->parent->mkpath; |
124
|
0
|
0
|
|
|
|
|
if (-f $cache) { |
125
|
0
|
|
|
|
|
|
return Load scalar $cache->slurp_utf8; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
my $initial = substr $distname, 0, 1; |
129
|
0
|
|
|
|
|
|
my $url = "http://www.cpantesters.org/distro/$initial/$distname.yml"; |
130
|
0
|
|
|
|
|
|
$mech->get($url); |
131
|
0
|
|
|
|
|
|
$cache->spew_utf8($mech->content); |
132
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
my $yaml = Load $mech->content; |
134
|
0
|
|
|
|
|
|
return $yaml; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
1; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__END__ |