From: Rafael Kitover Date: Mon, 12 Mar 2012 21:00:04 +0000 (-0400) Subject: Update t/751msaccess.t broken by leak checker 65d35121 X-Git-Tag: v0.08197~90 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=2d48959ab73f3f9a60cbcf42e115a1b724cb45cd Update t/751msaccess.t broken by leak checker 65d35121 Can't have the cleanup sub close over $schema. --- diff --git a/t/751msaccess.t b/t/751msaccess.t index 403dc21..48ff756 100644 --- a/t/751msaccess.t +++ b/t/751msaccess.t @@ -42,15 +42,13 @@ my @info = ( [ $dsn2, $user2 || '', $pass2 || '' ], ); -my $schema; - foreach my $info (@info) { my ($dsn, $user, $pass) = @$info; next unless $dsn; # Check that we can connect without any options. - $schema = DBICTest::Schema->connect($dsn, $user, $pass); + my $schema = DBICTest::Schema->connect($dsn, $user, $pass); lives_ok { $schema->storage->ensure_connected; } 'connection without any options'; @@ -66,7 +64,7 @@ foreach my $info (@info) { LongReadLen => $maxloblen, }); - my $guard = Scope::Guard->new(\&cleanup); + my $guard = Scope::Guard->new(sub { cleanup($schema) }); my $dbh = $schema->storage->dbh; @@ -442,6 +440,8 @@ SQL done_testing; sub cleanup { + my $schema = shift; + if (my $storage = eval { $schema->storage }) { # cannot drop a table if it has been used, have to reconnect first $schema->storage->disconnect;