for my $want (0,1) {
my $schema = DBICTest->init_schema;
- is( $schema->storage->{transaction_depth}, 0, 'txn depth starts at 0');
+ is( $schema->storage->transaction_depth, 0, 'txn depth starts at 0');
my @titles = map {'txn_do test CD ' . $_} (1..5);
my $artist = $schema->resultset('Artist')->find(1);
title => "txn_do test CD $_",
})->first->year, 2006, "new CD $_ year correct") for (1..5);
- is( $schema->storage->{transaction_depth}, 0, 'txn depth has been reset');
+ is( $schema->storage->transaction_depth, 0, 'txn depth has been reset');
}
# Test txn_do() @_ aliasing support
{
my $schema = DBICTest->init_schema;
- is( $schema->storage->{transaction_depth}, 0, 'txn depth starts at 0');
+ is( $schema->storage->transaction_depth, 0, 'txn depth starts at 0');
my $nested_code = sub {
my ($schema, $artist, $code) = @_;
})->first->year, 2006, qq{nested txn_do CD$_ year ok}) for (1..10);
is($artist->cds->count, $count_before+10, 'nested txn_do added all CDs');
- is( $schema->storage->{transaction_depth}, 0, 'txn depth has been reset');
+ is( $schema->storage->transaction_depth, 0, 'txn depth has been reset');
}
# test nested txn_begin on fresh connection
is ($schema->storage->transaction_depth, 0, 'Start outside txn');
my @pids;
+ SKIP:
for my $action (
sub {
my $s = shift;
},
) {
my $pid = fork();
- die "Unable to fork: $!\n"
- if ! defined $pid;
+
+ if( ! defined $pid ) {
+ skip "EAGAIN encountered, your system is likely bogged down: skipping forking test", 1
+ if $! == Errno::EAGAIN();
+
+ die "Unable to fork: $!"
+ }
if ($pid) {
push @pids, $pid;
if $^O eq 'MSWin32';
my $pid = fork();
- die "Unable to fork: $!\n"
- if ! defined $pid;
+ if( ! defined $pid ) {
+
+ skip "EAGAIN encountered, your system is likely bogged down: skipping forking test", 1
+ if $! == Errno::EAGAIN();
+
+ die "Unable to fork: $!"
+ }
if ($pid) {
push @pids, $pid;
# Test failed txn_do()
for my $pass (1,2) {
- is( $schema->storage->{transaction_depth}, 0, "txn depth starts at 0 (pass $pass)");
+ is( $schema->storage->transaction_depth, 0, "txn depth starts at 0 (pass $pass)");
my $artist = $schema->resultset('Artist')->find(3);
})->first;
ok(!defined($cd), qq{failed txn_do didn't change the cds table (pass $pass)});
- is( $schema->storage->{transaction_depth}, 0, "txn depth has been reset (pass $pass)");
+ is( $schema->storage->transaction_depth, 0, "txn depth has been reset (pass $pass)");
}
# Test failed txn_do() with failed rollback
{
- is( $schema->storage->{transaction_depth}, 0, 'txn depth starts at 0');
+ is( $schema->storage->transaction_depth, 0, 'txn depth starts at 0');
my $artist = $schema->resultset('Artist')->find(3);
{
my $schema = DBICTest->init_schema();
- is( $schema->storage->{transaction_depth}, 0, 'txn depth starts at 0');
+ is( $schema->storage->transaction_depth, 0, 'txn depth starts at 0');
my $nested_fail_code = sub {
my ($schema, $artist, $code1, $code2) = @_;
} qr/\QTransaction aborted: $broken_exception. Rollback failed: lost connection to storage at @{[__FILE__]} line $ln\E\n/; # FIXME wtf - ...\E$/m doesn't work here
is @w, 1, 'One matching warning only';
+
+ # try the same broken exception object, but have exception_action inject it
+ $s->exception_action(sub { die $broken_exception });
+ eval {
+ $s->txn_do( sub {
+ die "some string masked away";
+ });
+ };
+ isa_ok $@, 'DBICTest::BrokenOverload', 'Deficient exception properly propagated';
+
+ is @w, 2, 'The warning was emitted a second time';
}
done_testing;