use base qw(DBICTest::Base DBIx::Class::Schema);
use Fcntl qw(:DEFAULT :seek :flock);
+use IO::Handle ();
use DBIx::Class::_Util 'scope_guard';
use DBICTest::Util::LeakTracer qw(populate_weakregistry assert_empty_weakregistry);
use DBICTest::Util qw( local_umask tmpdir await_flock dbg DEBUG_TEST_CONCURRENCY_LOCKS );
use namespace::clean;
if( $ENV{DBICTEST_ASSERT_NO_SPURIOUS_EXCEPTION_ACTION} ) {
- __PACKAGE__->exception_action( sub {
+ my $ea = __PACKAGE__->exception_action( sub {
my ( $fr_num, $disarmed, $throw_exception_fr_num );
while( ! $disarmed and my @fr = caller(++$fr_num) ) {
) unless $disarmed;
DBIx::Class::Exception->throw( $_[0] );
- })
+ });
+
+ my $interesting_ns_rx = qr/^ (?: main$ | DBIx::Class:: | DBICTest:: ) /x;
+
+ # hard-set $SIG{__DIE__} to the class-wide exception_action
+ # with a little escape preceeding it
+ $SIG{__DIE__} = sub {
+
+ # without this there would be false positives everywhere :(
+ die @_ if (
+ (caller(0))[0] !~ $interesting_ns_rx
+ or
+ (
+ caller(0) eq 'main'
+ and
+ (caller(1))[0] !~ $interesting_ns_rx
+ )
+ );
+
+ &$ea;
+ };
}
sub capture_executed_sql_bind {
and
ref($_[0]) ne 'CODE'
and
- ($_[0]||'') !~ /^ (?i:dbi) \: SQLite \: (?: dbname\= )? (?: \:memory\: | t [\/\\] var [\/\\] DBIxClass\-) /x
+ ($_[0]||'') !~ /^ (?i:dbi) \: SQLite (?: \: | \W ) .*? (?: dbname\= )? (?: \:memory\: | t [\/\\] var [\/\\] DBIxClass\-) /x
) {
my $locktype;
# we need to work with a forced fresh clone so that we do not upset any state
# of the main $schema (some tests examine it quite closely)
local $SIG{__WARN__} = sub {};
+ local $SIG{__DIE__};
local $@;
# this will either give us an undef $locktype or will determine things
# properly with a default ( possibly connecting in the process )
eval {
- my $s = ref($self)->connect(@{$self->storage->connect_info})->storage;
+ my $cur_storage = $self->storage;
+
+ $cur_storage = $cur_storage->master
+ if $cur_storage->isa('DBIx::Class::Storage::DBI::Replicated');
+
+ my $s = ref($self)->connect(@{$cur_storage->connect_info})->storage;
$locktype = $s->sqlt_type || 'generic';