X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fglobal_destruction.t;h=5b7fc8559ec73a62c905edd56269932ccd22bc0a;hb=6b44e3b08d4d855e971ccb756fc2038a7cb206cb;hp=8b22c8d5ce410f5a2bc787ac5f27db7f30f096db;hpb=9dfb034ff8191ec4648a65ac99dd5e281c7040c3;p=dbsrgits%2FDBIx-Class.git diff --git a/t/storage/global_destruction.t b/t/storage/global_destruction.t index 8b22c8d..5b7fc85 100644 --- a/t/storage/global_destruction.t +++ b/t/storage/global_destruction.t @@ -1,72 +1,58 @@ +BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) } + use strict; use warnings; use Test::More; -use Test::Exception; + +# so we can see the retry exceptions (if any) +BEGIN { $ENV{DBIC_STORAGE_RETRY_DEBUG} = 1 } use DBIx::Class::Optional::Dependencies (); -use lib qw(t/lib); -use DBICTest; -plan skip_all => 'Test segfaults on Win32 - investigation pending' - if $^O eq 'MSWin32' && DBICTest::RunMode->is_plain; +use DBICTest; for my $type (qw/PG MYSQL SQLite/) { SKIP: { + + DBIx::Class::Optional::Dependencies->skip_without( 'test_rdbms_' . lc $type ); + 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/} - } + ? ( DBICTest->_database(sqlite_use_file => 1) ) + : ( @ENV{map { "DBICTEST_${type}_${_}" } qw/DSN USER PASS/} ) ; - if ($type eq 'PG') { - skip "skipping Pg tests without dependencies installed", 1 - unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_pg'); - } - elsif ($type eq 'MYSQL') { - skip "skipping MySQL tests without dependencies installed", 1 - unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mysql'); - } - 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 $DBICTest::FakeSchemaFactory::schema = $schema; - # so we can see the retry exceptions (if any) - $ENV{DBIC_DBIRETRY_DEBUG} = 1; - ok (!$schema->storage->connected, "$type: start disconnected"); - lives_ok (sub { - $schema->txn_do (sub { - - ok ($schema->storage->connected, "$type: transaction starts connected"); + $schema->txn_do (sub { - my $pid = fork(); - SKIP: { - skip "Fork failed: $!", 1 if (! defined $pid); + ok ($schema->storage->connected, "$type: transaction starts connected"); - if ($pid) { - note "Parent $$ sleeping..."; - wait(); - note "Parent $$ woken up after child $pid exit"; - } - else { - note "Child $$ terminating"; - undef $DBICTest::FakeSchemaFactory::schema; - exit 0; - } + my $pid = fork(); + SKIP: { + skip "Fork failed: $!", 1 if (! defined $pid); - 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)");