1 BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
8 # so we can see the retry exceptions (if any)
9 BEGIN { $ENV{DBIC_STORAGE_RETRY_DEBUG} = 1 }
11 use DBIx::Class::Optional::Dependencies ();
16 for my $type (qw/PG MYSQL SQLite/) {
19 my @dsn = $type eq 'SQLite'
20 ? DBICTest->_database(sqlite_use_file => 1)
22 skip "Skipping $type tests without DBICTEST_${type}_DSN", 1
23 unless $ENV{"DBICTEST_${type}_DSN"};
24 @ENV{map { "DBICTEST_${type}_${_}" } qw/DSN USER PASS/}
29 skip "skipping Pg tests without dependencies installed", 1
30 unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_pg');
32 elsif ($type eq 'MYSQL') {
33 skip "skipping MySQL tests without dependencies installed", 1
34 unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mysql');
37 my $schema = DBICTest::Schema->connect (@dsn);
39 # emulate a singleton-factory, just cache the object *somewhere in a different package*
40 # to induce out-of-order destruction
41 $DBICTest::FakeSchemaFactory::schema = $schema;
43 ok (!$schema->storage->connected, "$type: start disconnected");
45 $schema->txn_do (sub {
47 ok ($schema->storage->connected, "$type: transaction starts connected");
51 skip "Fork failed: $!", 1 if (! defined $pid);
54 note "Parent $$ sleeping...";
56 note "Parent $$ woken up after child $pid exit";
59 note "Child $$ terminating";
60 undef $DBICTest::FakeSchemaFactory::schema;
64 ok ($schema->storage->connected, "$type: parent still connected (in txn_do)");
68 ok ($schema->storage->connected, "$type: parent still connected (outside of txn_do)");
70 undef $DBICTest::FakeSchemaFactory::schema;