Fix MySQL skip counts
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / lib / dbixcsl_common_tests.pm
index 9c92e07..71f73fe 100644 (file)
@@ -12,7 +12,7 @@ use DBI;
 use Digest::MD5;
 use File::Find 'find';
 use Class::Unload ();
-use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file/;
+use DBIx::Class::Schema::Loader::Utils qw/dumper_squashed slurp_file sigwarn_silencer/;
 use List::MoreUtils 'apply';
 use DBIx::Class::Schema::Loader::Optional::Dependencies ();
 use Try::Tiny;
@@ -88,8 +88,11 @@ sub skip_tests {
 
 sub _monikerize {
     my $name = shift;
-    return 'LoaderTest2X' if $name =~ /^loader_test2$/i;
-    return undef;
+    my $orig = pop;
+    return $orig->({
+        loader_test2 => 'LoaderTest2X',
+        LOADER_TEST2 => 'LoaderTest2X',
+    });
 }
 
 sub run_tests {
@@ -625,7 +628,7 @@ qr/\n__PACKAGE__->load_components\("TestSchemaComponent", "\+TestSchemaComponent
         'is_nullable=1 detection';
 
     SKIP: {
-        skip $self->{skip_rels}, 137 if $self->{skip_rels};
+        skip $self->{skip_rels}, 145 if $self->{skip_rels};
 
         my $moniker3 = $monikers->{loader_test3};
         my $class3   = $classes->{loader_test3};
@@ -1094,7 +1097,7 @@ qr/\n__PACKAGE__->(?:belongs_to|has_many|might_have|has_one|many_to_many)\(
 
         # relname is preserved when another fk is added
         {
-            local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ /invalidates \d+ active statement/ };
+            local $SIG{__WARN__} = sigwarn_silencer(qr/invalidates \d+ active statement/);
             $conn->storage->disconnect; # for mssql and access
         }
 
@@ -1264,12 +1267,10 @@ TODO: {
 
         my $guard = $conn->txn_scope_guard;
 
-        my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-        local $SIG{__WARN__} = sub {
-            $warn_handler->(@_)
-                unless $_[0] =~ RESCAN_WARNINGS
-                    || $_[0] =~ /commit ineffective with AutoCommit enabled/; # FIXME
-        };
+        my $rescan_warnings = RESCAN_WARNINGS;
+        local $SIG{__WARN__} = sigwarn_silencer(
+            qr/$rescan_warnings|commit ineffective with AutoCommit enabled/ # FIXME
+        );
 
         my $schema_from = DBIx::Class::Schema::Loader::make_schema_at(
             "TestSchemaFromAnother", \%opts, [ sub { $conn->storage->dbh } ]
@@ -2232,8 +2233,10 @@ sub setup_data_type_tests {
         @first_table_types = grep !/$split_off_re/, @types;
     }
 
-    @types = +{ map +($_, $types->{$_}), @first_table_types },
-        map +{ $_, $types->{$_} }, @split_off_types;
+    @types = (
+        +{ map +($_, $types->{$_}), @first_table_types },
+        map +{ $_, $types->{$_} }, @split_off_types,
+    );
 
     my $test_count = 0;
     my $table_num  = 10000;
@@ -2307,7 +2310,7 @@ sub setup_data_type_tests {
 sub rescan_without_warnings {
     my ($self, $conn) = @_;
 
-    local $SIG{__WARN__} = sub { warn @_ unless $_[0] =~ RESCAN_WARNINGS };
+    local $SIG{__WARN__} = sigwarn_silencer(RESCAN_WARNINGS);
     return $conn->rescan;
 }