File: zzzzzzz_sqlite_deadlock.t

package info (click to toggle)
libdbix-class-perl 0.08196-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 4,424 kB
  • sloc: perl: 22,328; sql: 362; makefile: 10
file content (45 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use strict;
use warnings;

use Test::More;
use Test::Exception;
use lib 't/lib';

use File::Temp ();
use DBICTest;
use DBICTest::Schema;

if ( DBICTest::RunMode->is_plain ) {
  plan( skip_all => "Skipping test on plain module install" );
}

plan tests => 2;
my $wait_for = 120;  # how many seconds to wait

for my $close (0,1) {

  my $tmp = File::Temp->new(
    UNLINK => 1,
    TMPDIR => 1,
    SUFFIX => '.sqlite',
    EXLOCK => 0,  # important for BSD and derivatives
  );

  my $tmp_fn = $tmp->filename;
  close $tmp if $close;

  local $SIG{ALRM} = sub { die sprintf (
    "Timeout of %d seconds reached (tempfile still open: %s)",
    $wait_for, $close ? 'No' : 'Yes'
  )};

  alarm $wait_for;

  lives_ok (sub {
    my $schema = DBICTest::Schema->connect ("DBI:SQLite:$tmp_fn");
    DBICTest->deploy_schema ($schema);
    #DBICTest->populate_schema ($schema);
  });

  alarm 0;
}