updated dependents test
[gitmo/Moo.git] / xt / test-my-dependents.t
CommitLineData
dcc862ca 1use Test::More;
2BEGIN {
c6bf1147 3 plan skip_all => <<'END_HELP' unless $ENV{MOO_TEST_MD} || @ARGV;
dcc862ca 4This test will not run unless you set MOO_TEST_MD to a true value.
5
6 Valid values are:
7
8 all Test every dist which depends on Moose except those
9 that we know cannot be tested. This is a lot of
10 distros (hundreds).
11
12 Dist::1,Dist::2,... Test the individual dists listed.
13
14 MooX Test all Moo extension distros.
15
16 1 Run the default tests. We pick 200 random dists and
17 test them.
18END_HELP
19}
20
37d01587 21use Test::DependentModules qw( test_module );
dcc862ca 22use MetaCPAN::API;
23use List::Util ();
24
4c58e020 25# avoid any modules that depend on these
26my @bad_prereqs = qw(Gtk2 Padre Wx);
27
dcc862ca 28my $mcpan = MetaCPAN::API->new;
29my $res = $mcpan->post(
30 '/search/reverse_dependencies/Moo' => {
31 query => {
32 filtered => {
33 query => { "match_all" => {} },
34 filter => {
35 and => [
36 { term => { 'release.status' => 'latest' } },
37 { term => { 'release.authorized' => \1 } },
4c58e020 38 { not => { filter => {
39 or => [
40 map { { term => { 'dependency.module' => $_ } } } @bad_prereqs,
41 ],
42 } } }
dcc862ca 43 ],
44 },
45 },
46 },
47 size => 5000,
4c58e020 48 fields => ['distribution', 'provides', 'metadata.provides'],
dcc862ca 49 },
50);
51
15f328f0 52my %bad_dist;
37d01587 53my $sec_reason;
54my %skip;
55my %todo;
56
57my $hash;
58for my $line (<DATA>) {
dcc862ca 59 chomp $line;
37d01587 60 next unless $line =~ /\S/;
61 if ( $line =~ /^#\s*(\w+)(?::\s*(.*?)\s*)?$/ ) {
62 die "Invalid action in DATA section ($1)"
63 unless $1 eq 'SKIP' || $1 eq 'TODO';
64 $hash = $1 eq 'SKIP' ? \%skip : \%todo;
65 $sec_reason = $2;
dcc862ca 66 }
37d01587 67
68 my ( $dist, $reason ) = $line =~ /^(\S*)\s*(?:#\s*(.*?)\s*)?$/;
69 next unless defined $dist && length $dist;
70
a665e0b1 71 $hash->{$dist} = $reason ? "$sec_reason: $reason" : $reason;
dcc862ca 72}
73
37d01587 74my %todo_module;
75my @modules;
76for my $hit (@{ $res->{hits}{hits} }) {
77 my $dist = $hit->{fields}{distribution};
78 next
79 if exists $skip{$dist};
80 next
81 if $dist =~ /^(?:Task|Bundle|Acme)-/;
82
83 my $module = (sort { length $a <=> length $b || $a cmp $b } do {
bbecfc66 84 if (my $provides = $hit->{fields}{provides}) {
15f328f0 85 ref $provides ? @$provides : ($provides);
86 }
bbecfc66 87 elsif (my $provides = $hit->{fields}{'metadata.provides'}) {
15f328f0 88 keys %$provides;
89 }
90 else {
91 (my $module = $dist) =~ s/-/::/g;
92 ($module);
93 }
37d01587 94 })[0];
95 $todo_module{$module} = $todo{$dist}
96 if exists $todo{$dist};
97 push @modules, $module;
98 $module;
99}
100@modules = sort @modules;
dcc862ca 101
c6bf1147 102my @args = grep { $_ ne '--show' } @ARGV;
103my $show = @args != @ARGV;
104my $pick = $ENV{MOO_TEST_MD} || shift @args || 'all';
105
106if ( $pick eq 'MooX' ) {
dcc862ca 107 @modules = grep /^MooX(?:$|::)/, @modules;
108}
c6bf1147 109elsif ( $pick =~ /^\d+$/ ) {
110 my $count = $pick == 1 ? 200 : $pick;
111 diag(<<"EOF");
112 Picking $count random dependents to test. Set MOO_TEST_MD=all to test all
dcc862ca 113 dependents or MOO_TEST_MD=MooX to test extension modules only.
114EOF
c6bf1147 115 @modules = (List::Util::shuffle(@modules))[0 .. $count-1];
dcc862ca 116}
c6bf1147 117elsif ( $pick ne 'all' ) {
dcc862ca 118 my @chosen = split /,/, $ENV{MOO_TEST_MD};
119 my %modules = map { $_ => 1 } @modules;
120 if (my @unknown = grep { !$modules{$_} } @chosen) {
bbecfc66 121 die "Unknown modules: @unknown";
dcc862ca 122 }
123 @modules = @chosen;
124}
125
c6bf1147 126if ($show) {
37d01587 127 print "Dependents:\n";
15f328f0 128 print " $_\n" for @modules;
129 exit;
130}
131
dcc862ca 132plan tests => scalar @modules;
37d01587 133for my $module (@modules) {
134 local $TODO = $todo_module{$module} || '???'
135 if exists $todo_module{$module};
136 test_module($module);
137}
138
dcc862ca 139
140__DATA__
37d01587 141
a665e0b1 142# TODO: broken
824257db 143App-Presto # 0.009
144Dancer2-Session-Sereal # 0.001
145Mail-GcalReminder # 0.1
146DBIx-Class-IndexSearch-Dezi # 0.05
147Tak # 0.001003
148HTML-Zoom-Parser-HH5P # 0.002
149
150# TODO: broken prereqs
151Dancer-Plugin-FontSubset # 0.1.2 - Font::TTF::Scripts::Name
4c58e020 152
a665e0b1 153# TODO: broken by perl 5.18
824257db 154App-DBCritic # 0.020 - smartmatch (GH #9)
155App-OS-Detect-MachineCores # 0.038 - smartmatch (rt#88855)
156Authen-HTTP-Signature # 0.02 - smartmatch (rt#88854)
157DBICx-Backend-Move # 1.000010 - smartmatch (rt#88853)
158Ruby-VersionManager # 0.004003 - smartmatch (rt#88852)
159Text-Keywords # 0.900 - smartmatch (rt#84339)
160Log-Message-Structured-Stringify-AsSereal # 0.10 - hash order (GH #1)
161WebService-HabitRPG # 0.21 - smartmatch (rt#88399)
162App-Rssfilter # 0.03 - smartmatch (GH #2)
163Net-Icecast2 # 0.005 - hash order via PHP::HTTPBuildQuery (rt#81570)
164POE-Component-ProcTerminator # 0.03 - hash order via Log::Fu (rt#88851)
165
166# TODO: broken by Regexp::Grammars (perl 5.18)
167Data-Sah # 0.15
168Language-Expr # 0.19
169Org-To-HTML # 0.07 - via Language::Expr
170Perinci-Access-Simple-Server # 0.12
171Perinci-CmdLine # 0.85 - via Data::Sah
172Perinci-To-Text # 0.22 - via Data::Sah
173Perinci-Sub-To-Text # 0.24 - via Data::Sah
174Finance-Bank-ID-BCA # 0.26 - via Perinci::CmdLine
175Software-Release-Watch # 0.01 - via Data::Sah, Perinci::CmdLine
176Software-Release-Watch-SW-wordpress # 0.01 - via Software::Release::Watch
4c58e020 177
a665e0b1 178# SKIP: invalid prereqs
179Catmandu-Z3950 # 0.03 - ZOOM missing
180Dancer2-Session-JSON # 0.001 - Dancer2 bad version requirement
4c58e020 181
a665e0b1 182# SKIP: misc
b9dce248 183GeoIP2 # 0.040000 - prereq Math::Int128 (requires gcc 4.4)
184Graphics-Potrace # 0.72 - external dependency
185GraphViz2 # 2.19 - external dependency
a665e0b1 186Linux-AtaSmart # OS specific
b9dce248 187MaxMind-DB-Reader # 0.040003 - prereq Math::Int128 (requires gcc 4.4)
188MaxMind-DB-Common # 0.031002 - prereq Math::Int128 (requires gcc 4.4)
a665e0b1 189Net-Works # 0.12 - prereq Math::Int128 (requires gcc 4.4)
b9dce248 190PortageXS # 0.3.1 - external dependency and broken prereq (Shell::EnvImporter)
a665e0b1 191XML-GrammarBase # v0.2.2 - prereq XML::LibXSLT (hard to install)
192Forecast-IO # 0.21 - interactive tests
b9dce248 193Net-OpenVPN-Launcher # 0.1 - external dependency (and broken test)
194App-PerlWatcher-Level # 0.13 - depends on Linux::Inotify2
195Graph-Easy-Marpa # 2.00 - GraphVis2
824257db 196Net-OAuth-LP # 0.016 - relies on external service
197Message-Passing-ZeroMQ # 0.007 - external dependency
198Net-Docker # 0.002003 - external dependency
dcc862ca 199
37d01587 200# TODO: broken by Moo change
15f328f0 201Math-Rational-Approx # RT#84035
202App-Services # RT#85255
a665e0b1 203Hg-Lib # pending release