[Bast-commits] r8252 - in
DBIx-Class/0.08/branches/connected_schema_leak:
lib/DBIx/Class t t/schema
ribasushi at dev.catalyst.perl.org
ribasushi at dev.catalyst.perl.org
Fri Jan 8 14:52:46 GMT 2010
Author: ribasushi
Date: 2010-01-08 14:52:46 +0000 (Fri, 08 Jan 2010)
New Revision: 8252
Added:
DBIx-Class/0.08/branches/connected_schema_leak/t/schema/anon.t
Modified:
DBIx-Class/0.08/branches/connected_schema_leak/lib/DBIx/Class/Schema.pm
DBIx-Class/0.08/branches/connected_schema_leak/t/52cycle.t
Log:
Weird test failures
Modified: DBIx-Class/0.08/branches/connected_schema_leak/lib/DBIx/Class/Schema.pm
===================================================================
--- DBIx-Class/0.08/branches/connected_schema_leak/lib/DBIx/Class/Schema.pm 2010-01-08 14:43:38 UTC (rev 8251)
+++ DBIx-Class/0.08/branches/connected_schema_leak/lib/DBIx/Class/Schema.pm 2010-01-08 14:52:46 UTC (rev 8252)
@@ -5,7 +5,7 @@
use DBIx::Class::Exception;
use Carp::Clan qw/^DBIx::Class/;
-use Scalar::Util qw/weaken/;
+use Scalar::Util ();
use File::Spec;
use Sub::Name ();
use Module::Find();
@@ -1295,7 +1295,7 @@
$source = $source->new({ %$source, source_name => $moniker });
$source->schema($self);
- weaken($source->{schema}) if ref($self);
+ Scalar::Util::weaken($source->{schema}) if ref($self);
my $rs_class = $source->result_class;
Modified: DBIx-Class/0.08/branches/connected_schema_leak/t/52cycle.t
===================================================================
--- DBIx-Class/0.08/branches/connected_schema_leak/t/52cycle.t 2010-01-08 14:43:38 UTC (rev 8251)
+++ DBIx-Class/0.08/branches/connected_schema_leak/t/52cycle.t 2010-01-08 14:52:46 UTC (rev 8252)
@@ -8,16 +8,36 @@
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";
- } else {
- plan tests => 1;
- }
+ };
}
use DBICTest;
use DBICTest::Schema;
+use Scalar::Util ();
import Test::Memory::Cycle;
-my $s = DBICTest::Schema->clone;
+my $weak;
-memory_cycle_ok($s, 'No cycles in schema');
+{
+ my $s = $weak->{schema} = DBICTest->init_schema;
+ memory_cycle_ok($s, 'No cycles in schema');
+
+ my $rs = $weak->{resultset} = $s->resultset ('Artist');
+ memory_cycle_ok($rs, 'No cycles in resultset');
+
+ my $rsrc = $weak->{resultsource} = $rs->result_source;
+ memory_cycle_ok($rsrc, 'No cycles in resultsource');
+
+ my $row = $weak->{row} = $rs->first;
+ memory_cycle_ok($row, 'No cycles in row');
+
+ Scalar::Util::weaken ($_) for values %$weak;
+ memory_cycle_ok($weak, 'No cycles in weak object collection');
+}
+
+for (keys %$weak) {
+ ok (! $weak->{$_}, "No $_ leaks");
+}
+
+done_testing;
Added: DBIx-Class/0.08/branches/connected_schema_leak/t/schema/anon.t
===================================================================
--- DBIx-Class/0.08/branches/connected_schema_leak/t/schema/anon.t (rev 0)
+++ DBIx-Class/0.08/branches/connected_schema_leak/t/schema/anon.t 2010-01-08 14:52:46 UTC (rev 8252)
@@ -0,0 +1,13 @@
+use strict;
+use warnings;
+use Test::More;
+use Test::Exception;
+
+use lib qw(t/lib);
+use DBICTest;
+
+lives_ok (sub {
+ DBICTest->init_schema()->resultset('Artist')->find({artistid => 1 })->update({name => 'anon test'});
+}, 'Schema object not lost in chaining');
+
+done_testing;
More information about the Bast-commits
mailing list