use lib qw(t/lib);
BEGIN {
- eval { require Test::Memory::Cycle; require Devel::Cycle };
- if ($@ or Devel::Cycle->VERSION < 1.10) {
- plan skip_all => "leak test needs Test::Memory::Cycle and Devel::Cycle >= 1.10";
- };
+ require DBIx::Class;
+ plan skip_all => 'Test needs: ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_cycle')
+ unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_cycle') );
}
use DBICTest;
use DBICTest::Schema;
-use Scalar::Util ();
+use Scalar::Util 'weaken';
+use namespace::clean;
import Test::Memory::Cycle;
{
my $s = $weak->{schema} = DBICTest->init_schema;
+ ok ($s->storage->connected, 'we are connected');
memory_cycle_ok($s, 'No cycles in schema');
+ my $storage = $weak->{storage} = $s->storage;
+ memory_cycle_ok($storage, 'No cycles in storage');
+
+ my $dbh = $weak->{dbh} = $s->storage->_get_dbh;
+ memory_cycle_ok($dbh, 'No cycles in DBI handle');
+
+ my $sqla = $weak->{sqla} = $s->storage->sql_maker;
+ memory_cycle_ok($sqla, 'No cycles in SQL maker');
+
my $rs = $weak->{resultset} = $s->resultset ('Artist');
memory_cycle_ok($rs, 'No cycles in resultset');
my $row = $weak->{row} = $rs->first;
memory_cycle_ok($row, 'No cycles in row');
- Scalar::Util::weaken ($_) for values %$weak;
+ weaken $_ for values %$weak;
memory_cycle_ok($weak, 'No cycles in weak object collection');
}