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