Commit | Line | Data |
0ee285f3 |
1 | use inc::Module::Install 0.79; |
fe650234 |
2 | use strict; |
3 | use warnings; |
76607ac8 |
4 | use POSIX (); |
fe650234 |
5 | |
6 | use 5.006001; # delete this line if you want to send patches for earlier. |
ce4c07df |
7 | |
8 | name 'DBIx-Class'; |
ce4c07df |
9 | perl_version '5.006001'; |
8e0f16f1 |
10 | all_from 'lib/DBIx/Class.pm'; |
ce4c07df |
11 | |
0ee285f3 |
12 | # configure_requires so _check_sqlite() below can run |
13 | # remove once test deprecated |
14 | configure_requires 'DBD::SQLite'; |
15 | |
2f8a12ff |
16 | requires 'DBD::SQLite' => 1.25; |
82fae370 |
17 | requires 'Data::Page' => 2.00; |
1cbd3034 |
18 | requires 'SQL::Abstract' => 1.56; |
82fae370 |
19 | requires 'SQL::Abstract::Limit' => 0.13; |
624764ae |
20 | requires 'Class::C3::Componentised' => 1.0005; |
2f8a12ff |
21 | requires 'Carp::Clan' => 6.0; |
22 | requires 'DBI' => 1.605; |
23 | requires 'Module::Find' => 0.06; |
24 | requires 'Class::Inspector' => 1.24; |
2d60be4d |
25 | requires 'Class::Accessor::Grouped' => 0.08003; |
2f8a12ff |
26 | requires 'JSON::Any' => 1.18; |
82fae370 |
27 | requires 'Scope::Guard' => 0.03; |
2f8a12ff |
28 | requires 'Path::Class' => 0.16; |
82fae370 |
29 | requires 'Sub::Name' => 0.04; |
0fdb7298 |
30 | requires 'MRO::Compat' => 0.09; |
ce4c07df |
31 | |
2f8a12ff |
32 | # Core |
33 | requires 'List::Util' => 0; |
34 | requires 'Scalar::Util' => 0; |
35 | requires 'Storable' => 0; |
36 | |
ce4c07df |
37 | # Perl 5.8.0 doesn't have utf8::is_utf8() |
2f8a12ff |
38 | requires 'Encode' => 0 if ($] <= 5.008000); |
ce4c07df |
39 | |
2f8a12ff |
40 | test_requires 'Test::More' => 0.82; |
f947585b |
41 | test_requires 'Test::Builder' => 0.33; |
97aca715 |
42 | test_requires 'Test::Warn' => 0.11; |
f947585b |
43 | test_requires 'Test::Exception' => 0; |
ce3b4eb9 |
44 | test_requires 'Test::Deep' => 0; |
ce4c07df |
45 | |
82fae370 |
46 | recommends 'SQL::Translator' => 0.09004; |
47 | |
0ee285f3 |
48 | install_script (qw| |
49 | script/dbicadmin |
50 | |); |
ce4c07df |
51 | |
0ee285f3 |
52 | tests_recursive (qw| |
53 | t |
54 | |); |
ce4c07df |
55 | |
c96454c3 |
56 | # re-build README and require extra modules for testing if we're in a checkout |
fe650234 |
57 | |
82fae370 |
58 | my %force_requires_if_author = ( |
c96454c3 |
59 | 'Test::Pod::Coverage' => 1.04, |
9ac2c0f8 |
60 | 'SQL::Translator' => 0.09004, |
61 | |
62 | # CDBI-compat related |
82fae370 |
63 | 'DBIx::ContextualFetch' => 0, |
602fd807 |
64 | 'Class::DBI::Plugin::DeepAbstractSearch' => 0, |
82fae370 |
65 | 'Class::Trigger' => 0, |
97d61088 |
66 | 'Time::Piece::MySQL' => 0, |
82fae370 |
67 | 'Clone' => 0, |
97d61088 |
68 | 'Date::Simple' => 0, |
9ac2c0f8 |
69 | |
70 | # t/52cycle.t |
82fae370 |
71 | 'Test::Memory::Cycle' => 0, |
9ac2c0f8 |
72 | |
c96454c3 |
73 | # t/60core.t |
74 | 'DateTime::Format::MySQL' => 0, |
6c99a3ee |
75 | |
76 | # t/89inflate_datetime.t |
77 | 'DateTime::Format::Pg' => 0, |
c96454c3 |
78 | |
9d2b098e |
79 | # t/72pg.t |
80 | $ENV{DBICTEST_PG_DSN} |
81 | ? ('Sys::SigAction'=> 0) |
82 | : () |
83 | , |
84 | |
9ac2c0f8 |
85 | # t/93storage_replication.t |
ee356d00 |
86 | 'Moose', => 0.77, |
0ee285f3 |
87 | 'MooseX::AttributeHelpers' => 0.12, |
9901aad7 |
88 | 'MooseX::Types', => 0.10, |
89 | 'namespace::clean' => 0.11, |
b88b85e7 |
90 | 'Hash::Merge', => 0.11, |
c96454c3 |
91 | |
92 | # t/96_is_deteministic_value.t |
93 | 'DateTime::Format::Strptime' => 0, |
fe650234 |
94 | ); |
95 | |
96 | if ($Module::Install::AUTHOR) { |
97 | |
82fae370 |
98 | foreach my $module (keys %force_requires_if_author) { |
6882de2b |
99 | build_requires ($module => $force_requires_if_author{$module}); |
fe650234 |
100 | } |
09d46657 |
101 | |
1543db24 |
102 | system('pod2text lib/DBIx/Class.pm > README'); |
ff132c6f |
103 | } |
104 | |
105 | auto_provides; |
106 | |
d7fda552 |
107 | if ($Module::Install::AUTHOR) { |
108 | warn <<'EOW'; |
109 | ****************************************************************************** |
110 | ****************************************************************************** |
111 | *** *** |
112 | *** AUTHOR MODE: all optional test dependencies converted to hard requires *** |
113 | *** *** |
114 | ****************************************************************************** |
115 | ****************************************************************************** |
116 | |
117 | EOW |
118 | } |
3e110410 |
119 | auto_install; |
120 | |
e0b438fb |
121 | # Have all prerequisites, check DBD::SQLite sanity |
713cc98e |
122 | _check_sqlite() if (! $ENV{DBICTEST_NO_SQLITE_CHECK} ); |
269228af |
123 | |
713cc98e |
124 | WriteAll(); |
269228af |
125 | |
713cc98e |
126 | if ($Module::Install::AUTHOR) { |
127 | # Need to do this _after_ WriteAll else it loses track of them |
128 | Meta->{values}{build_requires} = [ grep { |
129 | my $ok = 1; |
130 | foreach my $module (keys %force_requires_if_author) { |
131 | if ($_->[0] =~ /$module/) { |
132 | $ok = 0; |
133 | last; |
134 | } |
135 | } |
136 | $ok; |
137 | } @{Meta->{values}{build_requires}} ]; |
269228af |
138 | |
713cc98e |
139 | Meta->{values}{resources} = [ |
140 | [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ], |
141 | [ 'IRC', 'irc://irc.perl.org/#dbix-class' ], |
142 | [ 'license', 'http://dev.perl.org/licenses/' ], |
143 | [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ], |
144 | ]; |
145 | Meta->write; |
146 | } |
269228af |
147 | |
269228af |
148 | |
713cc98e |
149 | # This is legacy code. Latest DBD::SQLite developments fixed all known bugs |
150 | # in this area. Remove before some arbitrary next version |
151 | sub _check_sqlite { |
e0b438fb |
152 | |
713cc98e |
153 | # Win32 does not have real fork()s so a segfault will bring |
154 | # everything down. Warn about it below, and don't try fork() |
155 | if ($^O ne 'MSWin32') { |
156 | |
157 | my $pid = fork(); |
158 | if (not defined $pid) { |
159 | die "Unable to fork(): $!"; |
160 | } |
161 | elsif (! $pid) { |
162 | _torture_sqlite(); |
d1b53160 |
163 | exit 0; |
713cc98e |
164 | } |
165 | else { |
76607ac8 |
166 | eval { |
167 | local $SIG{ALRM} = sub { die "timeout\n" }; |
168 | alarm 5; |
169 | wait(); |
170 | alarm 0; |
171 | }; |
7a0e56cb |
172 | my $exception = $@; |
173 | |
e0b438fb |
174 | my $sig = $? & 127; |
7a0e56cb |
175 | |
713cc98e |
176 | # make sure process actually dies |
7a0e56cb |
177 | $exception && kill POSIX::SIGKILL(), $pid; |
178 | |
179 | if ($exception || $sig == POSIX::SIGSEGV() || $sig == POSIX::SIGABRT() |
3c086319 |
180 | || $sig == 7) { # 7 == SIGBUS, haven't seen it but just in case |
e0b438fb |
181 | warn (<<EOE); |
182 | |
3951a291 |
183 | ############################### WARNING ################################# |
184 | # # |
185 | # You are running a buggy version of DBD::SQLite known to randomly # |
186 | # segfault on errors. Even if you have the latest CPAN module version, # |
187 | # the sqlite3 dynamic library on this system might have been compiled # |
188 | # against an older buggy sqlite3 dev library (oddly DBD::SQLite will # |
189 | # prefer the system library against the one bundled with it). You are # |
190 | # strongly advised to resolve this issue before proceeding. # |
191 | # # |
192 | ######################################################################### |
e0b438fb |
193 | |
194 | EOE |
195 | my $ans = prompt ( |
196 | "The test suite of this module is almost certain to fail.\n" |
197 | . 'Do you really want to continue?', |
198 | 'no', |
199 | ); |
a86fdee9 |
200 | |
e0b438fb |
201 | exit 0 unless ($ans =~ /^y(es)?$/i); |
202 | } |
713cc98e |
203 | } |
e0b438fb |
204 | } |
e0b438fb |
205 | |
713cc98e |
206 | else { # the win32 version |
e0b438fb |
207 | |
713cc98e |
208 | print <<'EOW'; |
209 | ###################################################################### |
210 | # # |
211 | # A short stress-testing of DBD::SQLite will follow. If you have a # |
212 | # buggy library this might very well be the last text you will see # |
213 | # before the installation silently terminates. If this happens it # |
214 | # would mean that you are running a buggy version of DBD::SQLite # |
215 | # known to randomly segfault on errors. Even if you have the latest # |
216 | # CPAN module version, the system sqlite3 dynamic library might have # |
217 | # been compiled against an older buggy sqlite3 dev library (oddly # |
218 | # DBD::SQLite will prefer the system library against the one bundled # |
219 | # with it). You are strongly advised to resolve this issue before # |
220 | # proceeding. # |
221 | # # |
222 | # If this happens to you (this text is the last thing you see), and # |
223 | # you just want to install this module without worrying about the # |
224 | # tests (which will almost certainly fail) - set the environment # |
225 | # variable DBICTEST_NO_SQLITE_CHECK to a true value and try again. # |
226 | # # |
227 | ###################################################################### |
09d46657 |
228 | |
713cc98e |
229 | EOW |
09d46657 |
230 | |
713cc98e |
231 | _torture_sqlite(); |
09d46657 |
232 | } |
09d46657 |
233 | } |
9a3219ee |
234 | |
713cc98e |
235 | sub _torture_sqlite { |
236 | require DBI; |
237 | |
238 | for (1 .. 100) { |
239 | my $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, { |
240 | AutoCommit => 1, |
241 | RaiseError => 0, |
242 | PrintError => 0, |
243 | }) or die "Unable to connect to database: $@"; |
244 | |
245 | $dbh->do ('CREATE TABLE name_with_no_columns'); # a subtle syntax error |
246 | $dbh->do ('COMMIT'); # followed by commit |
247 | $dbh->disconnect; |
248 | } |
713cc98e |
249 | } |