Reorganize runmode detection a bit
[dbsrgits/DBIx-Class.git] / t / zzzzzzz_sqlite_deadlock.t
CommitLineData
d7b94f7a 1use strict;
2use warnings;
3
4use Test::More;
5use Test::Exception;
6use lib 't/lib';
7
8use File::Temp ();
9use DBICTest;
10use DBICTest::Schema;
11
39c9c72d 12if ( DBICTest::RunMode->is_plain ) {
d096e13f 13 plan( skip_all => "Skipping test on plain module install" );
14}
15
d7b94f7a 16plan tests => 2;
39c9c72d 17my $wait_for = 120; # how many seconds to wait
d7b94f7a 18
19for my $close (0,1) {
20
f86589ef 21 my $tmp = File::Temp->new(
22 UNLINK => 1,
23 TMPDIR => 1,
24 SUFFIX => '.sqlite',
25 EXLOCK => 0, # important for BSD and derivatives
26 );
27
d7b94f7a 28 my $tmp_fn = $tmp->filename;
29 close $tmp if $close;
30
31 local $SIG{ALRM} = sub { die sprintf (
32 "Timeout of %d seconds reached (tempfile still open: %s)",
33 $wait_for, $close ? 'No' : 'Yes'
34 )};
35
36 alarm $wait_for;
37
38 lives_ok (sub {
39 my $schema = DBICTest::Schema->connect ("DBI:SQLite:$tmp_fn");
d7b94f7a 40 DBICTest->deploy_schema ($schema);
f86589ef 41 #DBICTest->populate_schema ($schema);
d7b94f7a 42 });
43
44 alarm 0;
45}