From: Rafael Kitover Date: Tue, 25 May 2010 18:32:39 +0000 (+0000) Subject: fix hang in SQLAnywhere DateTime tests X-Git-Tag: v0.08122~57^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=592ff7c47c6aa82b37925b5b7a6fc25d1e7f0f36;p=dbsrgits%2FDBIx-Class.git fix hang in SQLAnywhere DateTime tests --- diff --git a/t/inflate/datetime_sybase_asa.t b/t/inflate/datetime_sybase_asa.t index 761234d..88049be 100644 --- a/t/inflate/datetime_sybase_asa.t +++ b/t/inflate/datetime_sybase_asa.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use Test::Exception; +use Scope::Guard (); use lib qw(t/lib); use DBICTest; @@ -27,20 +28,20 @@ my @info = ( [ $dsn2, $user2, $pass2 ], ); -my @handles_to_clean; +my $schema; foreach my $info (@info) { my ($dsn, $user, $pass) = @$info; next unless $dsn; - my $schema = DBICTest::Schema->clone; + $schema = DBICTest::Schema->clone; $schema->connection($dsn, $user, $pass, { on_connect_call => [ 'datetime_setup' ], }); - push @handles_to_clean, $schema->storage->dbh; + my $sg = Scope::Guard->new(\&cleanup); # coltype, col, date my @dt_types = ( @@ -72,7 +73,7 @@ SQL ->search({ trackid => $row->trackid }, { select => [$col] }) ->first ); - is( $row->$col, $dt, 'DateTime roundtrip' ); + is( $row->$col, $dt, "$type roundtrip" ); is $row->$col->nanosecond, $dt->nanosecond, 'nanoseconds survived' if 0+$dt->nanosecond; @@ -82,8 +83,8 @@ SQL done_testing; # clean up our mess -END { - foreach my $dbh (@handles_to_clean) { +sub cleanup { + if (my $dbh = $schema->storage->dbh) { eval { $dbh->do("DROP TABLE $_") } for qw/track/; } }