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