Merge 'current' into 'deprecate_CDA'
Rafael Kitover [Wed, 30 Dec 2009 21:01:16 +0000 (21:01 +0000)]
r22312@hlagh (orig r8185):  caelum | 2009-12-30 12:30:58 -0500
bump File::Path dep, fixup redefined warning handler
r22313@hlagh (orig r8186):  caelum | 2009-12-30 15:58:06 -0500
fix tests

Makefile.PL
lib/DBIx/Class/Schema/Loader/Base.pm
t/20invocations.t
t/24loader_subclass.t
t/backcompat/0.04006/20invocations.t
t/backcompat/0.04006/22dump.t
t/backcompat/0.04006/lib/dbixcsl_common_tests.pm

index 42c232b..947f9c7 100644 (file)
@@ -6,7 +6,7 @@ all_from       'lib/DBIx/Class/Schema/Loader.pm';
 test_requires 'Test::More'    => '0.94';
 test_requires 'DBI'           => '1.56';
 test_requires 'DBD::SQLite'   => '1.12';
-test_requires 'File::Path'    => 0;
+test_requires 'File::Path'    => '2.07';
 test_requires 'IPC::Open3'    => 0;
 test_requires 'Test::Exception';
 
index 8cb3bf6..f231928 100644 (file)
@@ -417,7 +417,7 @@ EOF
             my ($v) = $real_ver =~ /([1-9])/;
             $v = "v$v";
 
-            last if $v eq CURRENT_V;
+            last if $v eq CURRENT_V || $real_ver =~ /^0\.04999/;
 
             if (not %{ $self->naming }) {
                 warn <<"EOF" unless $ENV{SCHEMA_LOADER_BACKCOMPAT};
@@ -518,8 +518,10 @@ sub _load_external {
 
         if ($self->dynamic) { # load the class too
             # kill redefined warnings
+            my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
             local $SIG{__WARN__} = sub {
-                warn @_ unless $_[0] =~ /^Subroutine \S+ redefined/;
+                $warn_handler->(@_)
+                    unless $_[0] =~ /^Subroutine \S+ redefined/;
             };
             do $real_inc_path;
             die $@ if $@;
@@ -545,8 +547,10 @@ been used by an 0.04006 version of the Loader.
 new name of the Result.
 EOF
             # kill redefined warnings
+            my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
             local $SIG{__WARN__} = sub {
-                warn @_ unless $_[0] =~ /^Subroutine \S+ redefined/;
+                $warn_handler->(@_)
+                    unless $_[0] =~ /^Subroutine \S+ redefined/;
             };
             my $code = do {
                 local ($/, @ARGV) = (undef, $old_real_inc_path); <>
@@ -736,10 +740,11 @@ sub _reload_class {
     delete $INC{ $class_path };
 
 # kill redefined warnings
+    my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
     local $SIG{__WARN__} = sub {
-        warn @_ unless $_[0] =~ /^Subroutine \S+ redefined/;
+        $warn_handler->(@_)
+            unless $_[0] =~ /^Subroutine \S+ redefined/;
     };
-
     eval "require $class;";
 }
 
index 3c59d9d..9d5ad65 100644 (file)
@@ -28,6 +28,7 @@ my @invocations = (
     'hardcode' => sub {
         package DBICTest::Schema::5;
         use base qw/ DBIx::Class::Schema::Loader /;
+        __PACKAGE__->naming('current');
         __PACKAGE__->connection($make_dbictest_db::dsn);
         __PACKAGE__;
     },
@@ -35,13 +36,14 @@ my @invocations = (
         package DBICTest::Schema::6;
         use base qw/ DBIx::Class::Schema::Loader /;
         __PACKAGE__->loader_options();
+        __PACKAGE__->naming('current');
         __PACKAGE__->connect($make_dbictest_db::dsn);
     },
     'make_schema_at' => sub {
         use DBIx::Class::Schema::Loader qw/ make_schema_at /;
         make_schema_at(
             'DBICTest::Schema::7',
-            { really_erase_my_files => 1 },
+            { really_erase_my_files => 1, naming => 'current' },
             [ $make_dbictest_db::dsn ],
         );
         DBICTest::Schema::7->clone;
@@ -49,6 +51,7 @@ my @invocations = (
     'embedded_options' => sub {
         package DBICTest::Schema::8;
         use base qw/ DBIx::Class::Schema::Loader /;
+        __PACKAGE__->naming('current');
         __PACKAGE__->connect(
             $make_dbictest_db::dsn,
             { loader_options => { really_erase_my_files => 1 } }
@@ -57,6 +60,7 @@ my @invocations = (
     'embedded_options_in_attrs' => sub {
         package DBICTest::Schema::9;
         use base qw/ DBIx::Class::Schema::Loader /;
+        __PACKAGE__->naming('current');
         __PACKAGE__->connect(
             $make_dbictest_db::dsn,
             undef,
@@ -71,7 +75,10 @@ my @invocations = (
             { },
             [
                 $make_dbictest_db::dsn,
-                { loader_options => { really_erase_my_files => 1 } },
+                { loader_options => {
+                    really_erase_my_files => 1,
+                    naming => 'current'
+                } },
             ],
         );
         "DBICTest::Schema::10";
@@ -79,7 +86,10 @@ my @invocations = (
     'almost_embedded' => sub {
         package DBICTest::Schema::11;
         use base qw/ DBIx::Class::Schema::Loader /;
-        __PACKAGE__->loader_options( really_erase_my_files => 1 );
+        __PACKAGE__->loader_options(
+            really_erase_my_files => 1,
+            naming => 'current'
+        );
         __PACKAGE__->connect(
             $make_dbictest_db::dsn,
             undef, undef, { AutoCommit => 1 }
@@ -89,7 +99,7 @@ my @invocations = (
         use DBIx::Class::Schema::Loader;
         DBIx::Class::Schema::Loader::make_schema_at(
             'DBICTest::Schema::12',
-            { really_erase_my_files => 1 },
+            { really_erase_my_files => 1, naming => 'current' },
             [ $make_dbictest_db::dsn ],
         );
         DBICTest::Schema::12->clone;
index 143c5db..66d24df 100644 (file)
@@ -12,19 +12,21 @@ my %invocations = (
     loader_class => sub {
         package DBICTest::Schema::1;
         use base qw/ DBIx::Class::Schema::Loader /;
+        __PACKAGE__->naming('current');
         __PACKAGE__->loader_class(shift);
         __PACKAGE__->connect($make_dbictest_db::dsn);
     },
     connect_info => sub {
         package DBICTeset::Schema::2;
         use base qw/ DBIx::Class::Schema::Loader /;
+        __PACKAGE__->naming('current');
         __PACKAGE__->connect($make_dbictest_db::dsn, { loader_class => shift });
     },
     make_schema_at => sub {
         use DBIx::Class::Schema::Loader qw/ make_schema_at /;
         make_schema_at(
             'DBICTeset::Schema::3',
-            { },
+            { naming => 'current' },
             [ $make_dbictest_db::dsn, { loader_class => shift } ]
         );
     }
index bd8850b..6060355 100644 (file)
@@ -6,6 +6,10 @@ use make_dbictest_db;
 plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests'
     unless $ENV{SCHEMA_LOADER_TESTS_BACKCOMPAT};
 
+local $SIG{__WARN__} = sub {
+    warn @_ unless $_[0] =~ /Dynamic schema|really_erase_my_files/;
+};
+
 # Takes a $schema as input, runs 4 basic tests
 sub test_schema {
     my ($testname, $schema) = @_;
index d067a60..fb609d2 100644 (file)
@@ -9,6 +9,11 @@ plan skip_all => 'set SCHEMA_LOADER_TESTS_BACKCOMPAT to enable these tests'
 
 my $dump_path = './t/_dump';
 
+local $SIG{__WARN__} = sub {
+    warn @_ unless $_[0] =~
+        /^Dumping manual schema|really_erase_my_files|^Schema dump complete/;
+};
+
 {
     package DBICTest::Schema::1;
     use base qw/ DBIx::Class::Schema::Loader /;
index e4e2517..42c53fa 100644 (file)
@@ -88,6 +88,7 @@ sub run_tests {
 
         my $warn_count = 0;
         $warn_count++ if grep /ResultSetManager/, @loader_warnings;
+        $warn_count++ if grep /Dynamic schema detected/, @loader_warnings;
 
         if($self->{skip_rels}) {
             is(scalar(@loader_warnings), $warn_count)
@@ -500,9 +501,17 @@ sub run_tests {
             q{ INSERT INTO loader_test30 (id,loader_test2) VALUES(321, 2) },
         );
 
-        my $dbh = $self->dbconnect(1);
-        $dbh->do($_) for @statements_rescan;
-        $dbh->disconnect;
+        {
+            # Silence annoying but harmless postgres "NOTICE:  CREATE TABLE..."
+            local $SIG{__WARN__} = sub {
+                my $msg = shift;
+                warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
+            };
+
+            my $dbh = $self->dbconnect(1);
+            $dbh->do($_) for @statements_rescan;
+            $dbh->disconnect;
+        }
 
         my @new = $conn->rescan;
         is(scalar(@new), 1);
@@ -852,7 +861,7 @@ sub create {
     # Silence annoying but harmless postgres "NOTICE:  CREATE TABLE..."
     local $SIG{__WARN__} = sub {
         my $msg = shift;
-        print STDERR $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
+        warn $msg unless $msg =~ m{^NOTICE:\s+CREATE TABLE};
     };
 
     $dbh->do($_) for (@statements);