Commit | Line | Data |
dcc862ca |
1 | use Test::More; |
2 | BEGIN { |
c6bf1147 |
3 | plan skip_all => <<'END_HELP' unless $ENV{MOO_TEST_MD} || @ARGV; |
dcc862ca |
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 | |
37d01587 |
21 | use Test::DependentModules qw( test_module ); |
dcc862ca |
22 | use MetaCPAN::API; |
23 | use List::Util (); |
24 | |
4c58e020 |
25 | # avoid any modules that depend on these |
26 | my @bad_prereqs = qw(Gtk2 Padre Wx); |
27 | |
dcc862ca |
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 } }, |
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 |
52 | my %bad_dist; |
37d01587 |
53 | my $sec_reason; |
54 | my %skip; |
55 | my %todo; |
56 | |
57 | my $hash; |
58 | for 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 | |
71 | $hash->{$dist} = $reason || $sec_reason; |
dcc862ca |
72 | } |
73 | |
37d01587 |
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 { |
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 |
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' ) { |
dcc862ca |
107 | @modules = grep /^MooX(?:$|::)/, @modules; |
108 | } |
c6bf1147 |
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 |
dcc862ca |
113 | dependents or MOO_TEST_MD=MooX to test extension modules only. |
114 | EOF |
c6bf1147 |
115 | @modules = (List::Util::shuffle(@modules))[0 .. $count-1]; |
dcc862ca |
116 | } |
c6bf1147 |
117 | elsif ( $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 |
126 | if ($show) { |
37d01587 |
127 | print "Dependents:\n"; |
15f328f0 |
128 | print " $_\n" for @modules; |
129 | exit; |
130 | } |
131 | |
dcc862ca |
132 | plan tests => scalar @modules; |
37d01587 |
133 | for 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 | |
142 | # SKIP: no tests |
d2e9e5e0 |
143 | AnyMerchant |
15f328f0 |
144 | CPAN-Mirror-Finder |
145 | Catmandu-AlephX |
146 | Device-Hue |
147 | Novel-Robot |
148 | Novel-Robot-Browser |
149 | Novel-Robot-Parser |
d2e9e5e0 |
150 | Novel-Robot-Packer |
15f328f0 |
151 | Thrift-API-HiveClient |
152 | Tiezi-Robot-Parser |
d2e9e5e0 |
153 | Tiezi-Robot-Packer |
154 | WWW-ORCID |
4c58e020 |
155 | |
37d01587 |
156 | # SKIP: broken |
15f328f0 |
157 | App-Presto |
158 | Catmandu-Store-Lucy |
159 | Dancer2-Session-Sereal |
d2e9e5e0 |
160 | Dancer-Plugin-FontSubset |
15f328f0 |
161 | Data-Localize |
d2e9e5e0 |
162 | DBIx-Class-IndexSearch-Dezi |
163 | DBIx-FixtureLoader |
15f328f0 |
164 | Message-Passing-ZeroMQ |
4c58e020 |
165 | Tak |
166 | |
d2e9e5e0 |
167 | # SKIP: broken prereqs |
168 | App-Netdisco |
169 | DBIx-Table-TestDataGenerator |
170 | Perinci-CmdLine |
171 | Perinci-Sub-Gen-AccessTable-DBI |
172 | |
173 | # SKIP: unreliable prereqs |
174 | Finance-Bitcoin |
175 | |
37d01587 |
176 | # SKIP: broken tests |
15f328f0 |
177 | Template-Flute |
178 | Uninets-Check-Modules-HTTP |
179 | Uninets-Check-Modules-MongoDB |
180 | Uninets-Check-Modules-Redis |
d2e9e5e0 |
181 | Net-OAuth-LP # pod coverage |
4c58e020 |
182 | |
37d01587 |
183 | # SKIP: missing prereqs |
15f328f0 |
184 | Catmandu-Z3950 |
185 | Tiezi-Robot |
4c58e020 |
186 | |
37d01587 |
187 | # SKIP: bad prereq version listed |
15f328f0 |
188 | Dancer2-Session-Cookie |
189 | Dancer2-Session-JSON |
4c58e020 |
190 | |
37d01587 |
191 | # TODO: broken, pending release |
15f328f0 |
192 | Hg-Lib |
4c58e020 |
193 | |
37d01587 |
194 | # SKIP: OS specific |
15f328f0 |
195 | Linux-AtaSmart |
dcc862ca |
196 | |
37d01587 |
197 | # TODO: broken by Moo change |
15f328f0 |
198 | Math-Rational-Approx # RT#84035 |
199 | App-Services # RT#85255 |