a049f222202e87e86ade2f05e6bf1b745ecc8848
[dbsrgits/DBIx-Class.git] / t / zzzzzzz_sqlite_deadlock.t
1 use strict;
2 use warnings;
3
4 use Test::More;
5 use Test::Exception;
6 use lib 't/lib';
7
8 use File::Temp ();
9 use DBICTest;
10 use DBICTest::Schema;
11
12 unless ( DBICTest::AuthorCheck->is_author || $ENV{AUTOMATED_TESTING} || $ENV{RELEASE_TESTING} ) {
13   plan( skip_all => "Skipping test on plain module install" );
14 }
15
16 plan tests => 2;
17 my $wait_for = 30;  # how many seconds to wait
18
19 for my $close (0,1) {
20
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
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");
40     DBICTest->deploy_schema ($schema);
41     #DBICTest->populate_schema ($schema);
42   });
43
44   alarm 0;
45 }