8 my $err = shift and select STDERR
;
9 say "usage: $0 [--list]";
16 use HTML
::TreeBuilder
;
18 use Capture
::Tiny
qw( :all );
19 use Term
::ANSIColor
qw(:constants :constants256);
22 use Getopt
::Long
qw(:config bundling passthrough);
24 "help|?" => sub { usage
(0); },
25 "a|all!" => \
my $opt_a, # Also build for known FAIL (they might have fixed it)
26 "l|list!" => \
my $opt_l,
29 my $tm = shift // do {
30 (my $d = getcwd
) =~ s{.*CPAN/([^/]+)(?:/.*)?}{$1};
32 } or die "No module to check\n";
34 diag
("Testing used-by for $tm\n");
35 my %tm = map { $_ => 1 } qw( );
38 $ENV{AUTOMATED_TESTING
} = 1;
40 # - are FAIL not due to the mudule being tested (e.g. POD or signature mismatch)
41 # - that require interaction (not dealt with in distroprefs or %ENV)
42 # - are not proper dists (cannot use CPAN's ->test)
43 # - require external connections or special devices
44 my %skip = $opt_a ?
() : map { $_ => 1 } @
{{
46 "GSM-Gnokii", # External device
52 "App-Framework", # Questions
53 "CGI-Application-Framework", # Unmet prerequisites
54 "CohortExplorer", # Unmet prerequisites
55 "Connector", # no Makefile.PL (in Annelidous)
56 "Finance-Bank-DE-NetBank", # Module signatures
57 "RT-Extension-Assets-Import-CSV", # Questions
58 "RT-View-ConciseSpreadsheet", # Questions
59 # "Text-CSV-Track", # encoding, patch filed at RT
60 "Text-ECSV", # POD, spelling
61 "Text-MeCab", # Questions
62 "Text-TEI-Collate", # Unmet prerequisites
63 "Text-Tradition", # Unmet prerequisites
64 "Tripletail", # Makefile.PL broken
65 "WWW-Analytics-MultiTouch", # Unmet prerequisites
66 "Webservice-InterMine", # Unmet prerequisites
67 "YamlTime", # Unmet prerequisites
68 "chart", # Questions (in Apache::Wyrd)
70 "hwd", # Own tests fail
76 "Text-CSV_XS" => [ # Using Text::CSV, thus
77 "Text-CSV-Auto", # optionally _XS
83 my $ua = LWP
::UserAgent
->new (agent
=> "Opera/12.15");
85 sub get_from_cpantesters
87 my $url = "http://deps.cpantesters.org/depended-on-by.pl?dist=$tm";
88 my $rsp = $ua->request (HTTP
::Request
->new (GET
=> $url));
89 unless ($rsp->is_success) {
90 warn "deps failed: ", $rsp->status_line, "\n";
93 my $tree = HTML
::TreeBuilder
->new;
94 $tree->parse_content ($rsp->content);
96 foreach my $a ($tree->look_down (_tag
=> "a", href
=> qr{query=})) {
97 (my $h = $a->attr ("href")) =~ s{.*=}{};
101 } # get_from_cpantesters
105 my $url = "http://cpants.cpanauthors.org/dist/$tm/used_by";
106 my $rsp = $ua->request (HTTP
::Request
->new (GET
=> $url));
107 unless ($rsp->is_success) {
108 warn "cpants failed: ", $rsp->status_line, "\n";
111 my $tree = HTML
::TreeBuilder
->new;
112 $tree->parse_content ($rsp->content);
114 foreach my $a ($tree->look_down (_tag
=> "a", href
=> qr{/dist/})) {
115 (my $h = $a->attr ("href")) =~ s{.*dist/}{};
116 $h =~ m{^$tm\b} and next;
119 @h or diag
("$url might be rebuilding");
125 my $url = "https://metacpan.org/requires/distribution/$tm";
126 my $rsp = $ua->request (HTTP
::Request
->new (GET
=> $url));
127 unless ($rsp->is_success) {
128 warn "meta failed: ", $rsp->status_line, "\n";
131 my $tree = HTML
::TreeBuilder
->new;
132 $tree->parse_content ($rsp->content);
134 foreach my $a ($tree->look_down (_tag
=> "a", class => "ellipsis",
135 href
=> qr{/release/})) {
136 (my $h = $a->attr ("href")) =~ s{.*release/}{};
137 $h =~ m{^$tm\b} and next;
143 foreach my $h ( get_from_cpants
(),
144 get_from_cpantesters
(),
148 exists $skip{$h} || $h =~ m
{^( $tm (?
: $ | / )
153 (my $m = $h) =~ s/-/::/g;
158 ok
(1, "No dependents found");
164 ok
(1, $_) for sort keys %tm;
170 #$ENV{AUTOMATED_TESTING} = 1;
171 foreach my $m (sort keys %tm) {
172 my $mod = CPAN
::Shell
->expand ("Module", "/$m/") or next;
174 $rslt{$m} = [ [], capture
{ $mod->test } ];
175 $rslt{$m}[0] = [ $?
, $!, $@
];
176 # say $? ? RED."FAIL".RESET : GREEN."PASS".RESET;