X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fglobal_destruction.t;h=4fb49cb68032df4f2d7de8511be6cdf9561d01cc;hb=c863e1022571bfcc01fcbc4b690fbf3b72a12be8;hp=629f7b7192bd75db84029391994e87d002fc65c3;hpb=199fbc453ec03891d0e156d7353c5e992ba4de47;p=dbsrgits%2FDBIx-Class.git diff --git a/t/storage/global_destruction.t b/t/storage/global_destruction.t index 629f7b7..4fb49cb 100644 --- a/t/storage/global_destruction.t +++ b/t/storage/global_destruction.t @@ -2,18 +2,23 @@ use strict; use warnings; use Test::More; -use Test::Exception; use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -for my $type (qw/PG MYSQL/) { +for my $type (qw/PG MYSQL SQLite/) { SKIP: { - skip "Skipping $type tests without DBICTEST_${type}_DSN", 1 - unless $ENV{"DBICTEST_${type}_DSN"}; + my @dsn = $type eq 'SQLite' + ? DBICTest->_database(sqlite_use_file => 1) + : do { + skip "Skipping $type tests without DBICTEST_${type}_DSN", 1 + unless $ENV{"DBICTEST_${type}_DSN"}; + @ENV{map { "DBICTEST_${type}_${_}" } qw/DSN USER PASS/} + } + ; if ($type eq 'PG') { skip "skipping Pg tests without dependencies installed", 1 @@ -24,7 +29,7 @@ for my $type (qw/PG MYSQL/) { unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mysql'); } - my $schema = DBICTest::Schema->connect (@ENV{map { "DBICTEST_${type}_${_}" } qw/DSN USER PASS/}); + my $schema = DBICTest::Schema->connect (@dsn); # emulate a singleton-factory, just cache the object *somewhere in a different package* # to induce out-of-order destruction @@ -35,28 +40,27 @@ for my $type (qw/PG MYSQL/) { ok (!$schema->storage->connected, "$type: start disconnected"); - lives_ok (sub { - $schema->txn_do (sub { + $schema->txn_do (sub { - ok ($schema->storage->connected, "$type: transaction starts connected"); + ok ($schema->storage->connected, "$type: transaction starts connected"); - my $pid = fork(); - SKIP: { - skip "Fork failed: $!", 1 if (! defined $pid); + my $pid = fork(); + SKIP: { + skip "Fork failed: $!", 1 if (! defined $pid); - if ($pid) { - note "Parent $$ sleeping..."; - wait(); - note "Parent $$ woken up after child $pid exit"; - } - else { - note "Child $$ terminating"; - exit 0; - } - - ok ($schema->storage->connected, "$type: parent still connected (in txn_do)"); + if ($pid) { + note "Parent $$ sleeping..."; + wait(); + note "Parent $$ woken up after child $pid exit"; + } + else { + note "Child $$ terminating"; + undef $DBICTest::FakeSchemaFactory::schema; + exit 0; } - }); + + ok ($schema->storage->connected, "$type: parent still connected (in txn_do)"); + } }); ok ($schema->storage->connected, "$type: parent still connected (outside of txn_do)");