Release commit for 1.003000
[gitmo/Moo.git] / xt / test-my-dependents.t
1 use Test::More;
2 BEGIN {
3   plan skip_all => <<'END_HELP' unless $ENV{MOO_TEST_MD} || @ARGV;
4 This 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.
18 END_HELP
19 }
20
21 use Test::DependentModules qw( test_module );
22 use MetaCPAN::API;
23 use List::Util ();
24
25 # avoid any modules that depend on these
26 my @bad_prereqs = qw(Gtk2 Padre Wx);
27
28 my $mcpan = MetaCPAN::API->new;
29 my $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 } },
38             { not => { filter => {
39               or => [
40                 map { { term => { 'dependency.module' => $_ } } } @bad_prereqs,
41               ],
42             } } }
43           ],
44         },
45       },
46     },
47     size => 5000,
48     fields => ['distribution', 'provides', 'metadata.provides'],
49   },
50 );
51
52 my %bad_dist;
53 my $sec_reason;
54 my %skip;
55 my %todo;
56
57 my $hash;
58 for my $line (<DATA>) {
59   chomp $line;
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;
66   }
67
68   my ( $dist, $reason ) = $line =~ /^(\S*)\s*(?:#\s*(.*?)\s*)?$/;
69   next unless defined $dist && length $dist;
70
71   $hash->{$dist} = $reason ? "$sec_reason: $reason" : $reason;
72 }
73
74 my %todo_module;
75 my @modules;
76 for 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 {
84     if (my $provides = $hit->{fields}{provides}) {
85       ref $provides ? @$provides : ($provides);
86     }
87     elsif (my $provides = $hit->{fields}{'metadata.provides'}) {
88       keys %$provides;
89     }
90     else {
91       (my $module = $dist) =~ s/-/::/g;
92       ($module);
93     }
94   })[0];
95   $todo_module{$module} = $todo{$dist}
96     if exists $todo{$dist};
97   push @modules, $module;
98   $module;
99 }
100 @modules = sort @modules;
101
102 my @args = grep { $_ ne '--show' } @ARGV;
103 my $show = @args != @ARGV;
104 my $pick = $ENV{MOO_TEST_MD} || shift @args || 'all';
105
106 if ( $pick eq 'MooX' ) {
107   @modules = grep /^MooX(?:$|::)/, @modules;
108 }
109 elsif ( $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
113   dependents or MOO_TEST_MD=MooX to test extension modules only.
114 EOF
115   @modules = (List::Util::shuffle(@modules))[0 .. $count-1];
116 }
117 elsif ( $pick ne 'all' ) {
118   my @chosen = split /,/, $ENV{MOO_TEST_MD};
119   my %modules = map { $_ => 1 } @modules;
120   if (my @unknown = grep { !$modules{$_} } @chosen) {
121     die "Unknown modules: @unknown";
122   }
123   @modules = @chosen;
124 }
125
126 if ($show) {
127   print "Dependents:\n";
128   print "  $_\n" for @modules;
129   exit;
130 }
131
132 plan tests => scalar @modules;
133 for my $module (@modules) {
134   local $TODO = $todo_module{$module} || '???'
135     if exists $todo_module{$module};
136   test_module($module);
137 }
138
139
140 __DATA__
141
142 # SKIP: no tests
143 AnyMerchant
144 CPAN-Mirror-Finder
145 Catmandu-AlephX
146 Device-Hue
147 Novel-Robot
148 Novel-Robot-Browser
149 Novel-Robot-Parser
150 Novel-Robot-Packer
151 Thrift-API-HiveClient
152 Tiezi-Robot-Parser
153 Tiezi-Robot-Packer
154 WWW-ORCID
155
156 # TODO: broken
157 App-Presto
158 Catmandu-Store-Lucy
159 Dancer2-Session-Sereal
160 Dancer-Plugin-FontSubset
161 Data-Localize
162 DBIx-Class-IndexSearch-Dezi
163 DBIx-FixtureLoader
164 Message-Passing-ZeroMQ
165 Tak
166
167 # TODO: broken by perl 5.18
168 App-DBCritic                # 0.020 - smartmatch
169 App-OS-Detect-MachineCores  # 0.038 - smartmatch
170 Authen-HTTP-Signature       # 0.02 - smartmatch
171 DBICx-Backend-Move          # 1.000010 - smartmatch
172 POEx-ZMQ3                   # 0.060002 - smartmatch
173 Ruby-VersionManager         # 0.004003 - smartmatch
174 Text-Keywords               # 0.900 - smartmatch
175 Data-CloudWeights           # v0.9.2
176 HTML-Zoom-Parser-HH5P       # 0.002
177 Log-Message-Structured-Stringify-AsSereal   # 0.10
178
179 # TODO: broken prereqs
180 App-Netdisco
181 DBIx-Table-TestDataGenerator
182 Perinci-CmdLine
183 Perinci-Sub-Gen-AccessTable-DBI
184
185 # TODO: broken prereqs (perl 5.18)
186 App-Rssfilter   # 0.03 - Data::Alias
187 App-Zapzi       # 0.004 - HTTP::CookieJar
188 Code-Crypt      # 0.001000 - Crypt::DES
189 Data-Sah        # 0.15 - Regexp::Grammars
190 Language-Expr   # 0.19 - Regexp::Grammars
191 Net-Icecast2    # 0.005 - PHP::HTTPBuildQuery (hash order)
192 Org-To-HTML     # 0.07 - Language::Expr
193 POE-Component-ProcTerminator          # 0.03 - Log::Fu
194 Perinci-Access-Simple-Server          # 0.12 - Regexp::Grammars
195 Perinci-Sub-Gen-AccessTable           # 0.19 - Regexp::Grammars
196 Software-Release-Watch                # 0.01 - Data::Sah, Perinci::CmdLine
197 Software-Release-Watch-SW-wordpress   # 0.01 - Software::Release::Watch
198 Tiezi-Robot                           # 0.12 - Data::Dump::Streamer, SOAP::Lite
199 WebService-HabitRPG                   # 0.19 - Data::Alias
200
201 # TODO: broken tests
202 Template-Flute
203 Uninets-Check-Modules-HTTP
204 Uninets-Check-Modules-MongoDB
205 Uninets-Check-Modules-Redis
206 Net-OAuth-LP # pod coverage
207
208 # SKIP: invalid prereqs
209 Catmandu-Z3950        # 0.03 - ZOOM missing
210 Dancer2-Session-JSON  # 0.001 - Dancer2 bad version requirement
211
212 # SKIP: misc
213 Linux-AtaSmart    # OS specific
214 Net-Works         # 0.12 - prereq Math::Int128 (requires gcc 4.4)
215 XML-GrammarBase   # v0.2.2 - prereq XML::LibXSLT (hard to install)
216 Forecast-IO       # 0.21 - interactive tests
217
218 # TODO: broken by Moo change
219 Math-Rational-Approx        # RT#84035
220 App-Services                # RT#85255
221 Hg-Lib                      # pending release