X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fstorage%2Fexception.t;h=d96e336cfa23b812f1eefbb8d9c4bfd4c98fb573;hb=3b80fa31b60050d4c8df91457ba6fd51b579a7a6;hp=725a0ab2f5278aba76a4126393f00d5a2b9032a7;hpb=014fd55671aaf0e2060e31cc2e547661346f3106;p=dbsrgits%2FDBIx-Class.git diff --git a/t/storage/exception.t b/t/storage/exception.t index 725a0ab..d96e336 100644 --- a/t/storage/exception.t +++ b/t/storage/exception.t @@ -1,5 +1,3 @@ -#!/usr/bin/perl - use strict; use warnings; @@ -9,6 +7,8 @@ use lib qw(t/lib); use DBICTest; use DBICTest::Schema; +# make sure nothing eats the exceptions (an unchecked eval in Storage::DESTROY used to be a problem) + { package Dying::Storage; @@ -19,6 +19,7 @@ use DBICTest::Schema; sub _populate_dbh { my $self = shift; + my $death = $self->_dbi_connect_info->[3]{die}; die "storage test died: $death" if $death eq 'before_populate'; @@ -29,45 +30,13 @@ use DBICTest::Schema; } } -TODO: { -local $TODO = "I have no idea what is going on here... but it ain't right"; - for (qw/before_populate after_populate/) { - - dies_ok (sub { + throws_ok (sub { my $schema = DBICTest::Schema->clone; $schema->storage_type ('Dying::Storage'); $schema->connection (DBICTest->_database, { die => $_ }); $schema->storage->ensure_connected; - }, "$_ exception found"); -} - + }, qr/$_/, "$_ exception found"); } done_testing; - -__END__ -For reference - next::method goes to ::Storage::DBI::_populate_dbh -which is: - -sub _populate_dbh { - my ($self) = @_; - - my @info = @{$self->_dbi_connect_info || []}; - $self->_dbh(undef); # in case ->connected failed we might get sent here - $self->_dbh($self->_connect(@info)); - - $self->_conn_pid($$); - $self->_conn_tid(threads->tid) if $INC{'threads.pm'}; - - $self->_determine_driver; - - # Always set the transaction depth on connect, since - # there is no transaction in progress by definition - $self->{transaction_depth} = $self->_dbh_autocommit ? 0 : 1; - - $self->_run_connection_actions unless $self->{_in_determine_driver}; -} - -After further tracing it seems that if I die() before $self->_conn_pid($$) -the exception is propagated. If I die after it - it's lost. What The Fuck?!