Disable reconnect test except fpor when AUTHORS is set
[dbsrgits/DBIx-Class.git] / Makefile.PL
CommitLineData
737416a4 1use inc::Module::Install 0.67;
fe650234 2use strict;
3use warnings;
76607ac8 4use POSIX ();
fe650234 5
6use 5.006001; # delete this line if you want to send patches for earlier.
ce4c07df 7
8name 'DBIx-Class';
ce4c07df 9perl_version '5.006001';
8e0f16f1 10all_from 'lib/DBIx/Class.pm';
ce4c07df 11
82fae370 12requires 'Data::Page' => 2.00;
13requires 'Scalar::Util' => 0;
14requires 'SQL::Abstract' => 1.49;
15requires 'SQL::Abstract::Limit' => 0.13;
16requires 'Class::C3' => 0.20;
17requires 'Class::C3::Componentised' => 0;
18requires 'Storable' => 0;
19requires 'Carp::Clan' => 0;
20requires 'DBI' => 1.40;
21requires 'Module::Find' => 0;
22requires 'Class::Inspector' => 0;
23requires 'Class::Accessor::Grouped' => 0.08002;
24requires 'JSON::Any' => 1.17;
25requires 'Scope::Guard' => 0.03;
26requires 'Path::Class' => 0;
27requires 'List::Util' => 1.19;
28requires 'Sub::Name' => 0.04;
ce4c07df 29
30# Perl 5.8.0 doesn't have utf8::is_utf8()
82fae370 31requires 'Encode' => 0 if ($] <= 5.008000);
ce4c07df 32
9ac2c0f8 33# configure_requires so the sanity check below can run
82fae370 34configure_requires 'DBD::SQLite' => 1.14;
d9a898ca 35
f947585b 36test_requires 'Test::Builder' => 0.33;
97aca715 37test_requires 'Test::Warn' => 0.11;
f947585b 38test_requires 'Test::Exception' => 0;
ce3b4eb9 39test_requires 'Test::Deep' => 0;
ce4c07df 40
82fae370 41recommends 'SQL::Translator' => 0.09004;
42
ce4c07df 43install_script 'script/dbicadmin';
44
50891152 45tests_recursive 't';
ce4c07df 46
c96454c3 47# re-build README and require extra modules for testing if we're in a checkout
fe650234 48
82fae370 49my %force_requires_if_author = (
c96454c3 50 'Test::Pod::Coverage' => 1.04,
9ac2c0f8 51 'SQL::Translator' => 0.09004,
52
53 # CDBI-compat related
82fae370 54 'DBIx::ContextualFetch' => 0,
55 'Class::Trigger' => 0,
56 'Time::Piece' => 0,
57 'Clone' => 0,
9ac2c0f8 58
59 # t/52cycle.t
82fae370 60 'Test::Memory::Cycle' => 0,
9ac2c0f8 61
c96454c3 62 # t/60core.t
63 'DateTime::Format::MySQL' => 0,
64
9ac2c0f8 65 # t/93storage_replication.t
66 'Moose', => 0,
67 'MooseX::AttributeHelpers' => 0.12,
c96454c3 68
69 # t/96_is_deteministic_value.t
70 'DateTime::Format::Strptime' => 0,
fe650234 71);
72
73if ($Module::Install::AUTHOR) {
74
82fae370 75 foreach my $module (keys %force_requires_if_author) {
76 requires ($module => $force_requires_if_author{$module});
fe650234 77 }
09d46657 78
1543db24 79 system('pod2text lib/DBIx/Class.pm > README');
ff132c6f 80}
81
82auto_provides;
83
3e110410 84auto_install;
85
e0b438fb 86# Have all prerequisites, check DBD::SQLite sanity
269228af 87if (! $ENV{DBICTEST_NO_SQLITE_CHECK} ) {
88
e0b438fb 89 my $pid = fork();
90 if (not defined $pid) {
91 die "Unable to fork(): $!";
92 }
93 elsif (! $pid) {
269228af 94
95 # Win32 does not have real fork()s so a segfault will bring
96 # everything down. Warn about it.
97 if ($^O eq 'MSWin32') {
98 print <<'EOW';
99
100######################################################################
101# #
102# A short stress-testing of DBD::SQLite will follow. If you have a #
103# buggy library this might very well be the last text you will see #
104# before the installation silently terminates. If this happens it #
105# would mean that you are running a buggy version of DBD::SQLite #
106# known to randomly segfault on errors. Even if you have the latest #
3951a291 107# CPAN module version, the system sqlite3 dynamic library might have #
108# been compiled against an older buggy sqlite3 dev library (oddly #
109# DBD::SQLite will prefer the system library against the one bundled #
110# with it). You are strongly advised to resolve this issue before #
111# proceeding. #
269228af 112# #
113# If this happens to you (this text is the last thing you see), and #
114# you just want to install this module without worrying about the #
115# tests (which will almost certainly fail) - set the environment #
116# variable DBICTEST_NO_SQLITE_CHECK to a true value and try again. #
117# #
118######################################################################
119
120EOW
121 }
122
e0b438fb 123 require DBI;
269228af 124 for (1 .. 100) {
e0b438fb 125 my $dbh;
126 $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
127 AutoCommit => 1,
128 RaiseError => 0,
129 PrintError => 0,
130 })
131 or die "Unable to connect to database: $@";
132 $dbh->do ('CREATE TABLE name_with_no_columns'); # a subtle syntax error
133 $dbh->do ('COMMIT'); # followed by commit
134 $dbh->disconnect;
135 }
136
137 exit 0;
138 }
139 else {
76607ac8 140 eval {
141 local $SIG{ALRM} = sub { die "timeout\n" };
142 alarm 5;
143 wait();
144 alarm 0;
145 };
7a0e56cb 146 my $exception = $@;
147
e0b438fb 148 my $sig = $? & 127;
7a0e56cb 149
150# make sure process actually dies
151 $exception && kill POSIX::SIGKILL(), $pid;
152
153 if ($exception || $sig == POSIX::SIGSEGV() || $sig == POSIX::SIGABRT()
3c086319 154 || $sig == 7) { # 7 == SIGBUS, haven't seen it but just in case
e0b438fb 155 warn (<<EOE);
156
3951a291 157############################### WARNING #################################
158# #
159# You are running a buggy version of DBD::SQLite known to randomly #
160# segfault on errors. Even if you have the latest CPAN module version, #
161# the sqlite3 dynamic library on this system might have been compiled #
162# against an older buggy sqlite3 dev library (oddly DBD::SQLite will #
163# prefer the system library against the one bundled with it). You are #
164# strongly advised to resolve this issue before proceeding. #
165# #
166#########################################################################
e0b438fb 167
168EOE
169 my $ans = prompt (
170 "The test suite of this module is almost certain to fail.\n"
171 . 'Do you really want to continue?',
172 'no',
173 );
174 exit 0 unless ($ans =~ /^y(es)?$/i);
175 }
176 }
177}
178
179
43944e47 180WriteAll();
09d46657 181
182
183if ($Module::Install::AUTHOR) {
184 # Need to do this _after_ WriteAll else it looses track of them
185 Meta->{values}{build_requires} = [ grep {
fe650234 186 my $ok = 1;
82fae370 187 foreach my $module (keys %force_requires_if_author) {
fe650234 188 if ($_->[0] =~ /$module/) {
189 $ok = 0;
190 last;
191 }
192 }
193 $ok;
09d46657 194 } @{Meta->{values}{build_requires}} ];
195
196 my @scalar_keys = Module::Install::Metadata::Meta_TupleKeys();
fe650234 197 my $cr = Module::Install::Metadata->can("Meta_TupleKeys");
198 {
199 no warnings 'redefine';
200 *Module::Install::Metadata::Meta_TupleKeys = sub {
201 return $cr->(@_), 'resources';
202 };
09d46657 203 }
204 Meta->{values}{resources} = [
205 [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
206 [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
100dd0a8 207 [ 'license', 'http://dev.perl.org/licenses/' ],
208 [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
09d46657 209 ];
210 Meta->write;
211}