Older versions behave erratically in the new reentrant test
[dbsrgits/DBIx-Class.git] / Makefile.PL
1 use inc::Module::Install 0.67;
2 use strict;
3 use warnings;
4
5 use 5.006001; # delete this line if you want to send patches for earlier.
6
7 name     'DBIx-Class';
8 perl_version '5.006001';
9 all_from 'lib/DBIx/Class.pm';
10
11 requires 'Data::Page'                => 2.00;
12 requires 'Scalar::Util'              => 0;
13 requires 'SQL::Abstract'             => 1.20;
14 requires 'SQL::Abstract::Limit'      => 0.101;
15 requires 'Class::C3'                 => 0.13;
16 requires 'Class::C3::Componentised'  => 0;
17 requires 'Storable'                  => 0;
18 requires 'Carp::Clan'                => 0;
19 requires 'DBI'                       => 1.40;
20 requires 'Module::Find'              => 0;
21 requires 'Class::Inspector'          => 0;
22 requires 'Class::Accessor::Grouped'  => 0.05002;
23 requires 'JSON::Any'                 => 1.17;
24 requires 'Scope::Guard'              => 0.03;
25 requires 'Path::Class'               => 0;
26 requires 'List::Util'                => 1.19;
27 requires 'Sub::Name'                 => 0.04;
28
29 # Perl 5.8.0 doesn't have utf8::is_utf8()
30 requires 'Encode'                    => 0 if ($] <= 5.008000);  
31
32 test_requires 'DBD::SQLite'         => 1.14;
33 test_requires 'Test::Builder'       => 0.33;
34 test_requires 'Test::Warn'          => 0.11;
35 test_requires 'Test::Exception'     => 0;
36 test_requires 'Test::Deep'          => 0;
37
38 install_script 'script/dbicadmin';
39
40 tests_recursive 't';
41
42 # re-build README and require CDBI modules for testing if we're in a checkout
43
44 my @force_build_requires_if_author = qw(
45   DBIx::ContextualFetch
46   Class::Trigger
47   Time::Piece
48   Clone
49   Test::Pod::Coverage
50   Test::Memory::Cycle
51 );
52
53 if ($Module::Install::AUTHOR) {
54
55   foreach my $module (@force_build_requires_if_author) {
56     build_requires $module;
57   }
58
59   system('pod2text lib/DBIx/Class.pm > README');
60 }
61
62 auto_provides;
63
64 auto_install;
65
66 # Have all prerequisites, check DBD::SQLite sanity
67 if (! $ENV{DBICTEST_NO_SQLITE_CHECK} ) {
68
69   my $pid = fork();
70   if (not defined $pid) {
71       die "Unable to fork(): $!";
72   }
73   elsif (! $pid) {
74
75       # Win32 does not have real fork()s so a segfault will bring
76       # everything down. Warn about it.
77       if ($^O eq 'MSWin32') {
78         print <<'EOW';
79
80 ######################################################################
81 #                                                                    #
82 # A short stress-testing of DBD::SQLite will follow. If you have a   #
83 # buggy library this might very well be the last text you will see   #
84 # before the installation silently terminates. If this happens it    #
85 # would mean that you are running a buggy version of DBD::SQLite     #
86 # known to randomly segfault on errors. Even if you have the latest  #
87 # CPAN module version, the actual sqlite3 dynamic library might have #
88 # been compiled against an older buggy sqlite3 dev library. You are  #
89 # strongly advised to update DBD::SQLite.                            #
90 #                                                                    #
91 # If this happens to you (this text is the last thing you see), and  #
92 # you just want to install this module without worrying about the    #
93 # tests (which will almost certainly fail) - set the environment     #
94 # variable DBICTEST_NO_SQLITE_CHECK to a true value and try again.   #
95 #                                                                    #
96 ######################################################################
97
98 EOW
99       }
100
101       require DBI;
102       for (1 .. 100) {
103           my $dbh;
104           $dbh = DBI->connect ('dbi:SQLite::memory:', undef, undef, {
105               AutoCommit => 1,
106               RaiseError => 0,
107               PrintError => 0,
108           })
109               or die "Unable to connect to database: $@";
110           $dbh->do ('CREATE TABLE name_with_no_columns');   # a subtle syntax error
111           $dbh->do ('COMMIT');                              # followed by commit
112           $dbh->disconnect;
113       }
114
115       exit 0;
116   }
117   else {
118       wait();
119       my $sig = $? & 127;
120       if ($sig == 11) {
121           warn (<<EOE);
122
123 ############################### WARNING ###################################
124 #                                                                         #
125 # You are running a buggy version of DBD::SQLite known to randomly        #
126 # segfault on errors. Even if you have the latest CPAN module version,    #
127 # the actual sqlite3.so might have been compiled against an older buggy   #
128 # sqlite3 dev library. You are strongly advised to update DBD::SQLite.    #
129 #                                                                         #
130 ###########################################################################
131
132 EOE
133           my $ans = prompt (
134             "The test suite of this module is almost certain to fail.\n"
135             . 'Do you really want to continue?',
136             'no',
137           );
138           exit 0 unless ($ans =~ /^y(es)?$/i);
139       }
140   }
141 }
142
143
144 WriteAll;
145
146
147 if ($Module::Install::AUTHOR) {
148   # Need to do this _after_ WriteAll else it looses track of them
149   Meta->{values}{build_requires} = [ grep {
150     my $ok = 1;
151     foreach my $module (@force_build_requires_if_author) {
152       if ($_->[0] =~ /$module/) {
153         $ok = 0;
154         last;
155       }
156     }
157     $ok;
158   } @{Meta->{values}{build_requires}} ];
159
160   my @scalar_keys = Module::Install::Metadata::Meta_TupleKeys();
161   my $cr = Module::Install::Metadata->can("Meta_TupleKeys");
162   {
163     no warnings 'redefine';
164     *Module::Install::Metadata::Meta_TupleKeys = sub {
165       return $cr->(@_), 'resources';
166     };
167   }
168   Meta->{values}{resources} = [ 
169     [ 'MailingList', 'http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class' ],
170     [ 'IRC', 'irc://irc.perl.org/#dbix-class' ],
171     [ 'license', 'http://dev.perl.org/licenses/' ],
172     [ 'repository', 'http://dev.catalyst.perl.org/svnweb/bast/browse/DBIx-Class/' ],
173   ];
174   Meta->write;
175 }