Fix MySQL skip counts
[dbsrgits/DBIx-Class-Schema-Loader.git] / t / 10_07mssql_common.t
index 6382fc6..b7eeb80 100644 (file)
@@ -2,7 +2,8 @@ use strict;
 use warnings;
 use Test::More;
 use Test::Exception;
-use DBIx::Class::Schema::Loader::Utils 'warnings_exist_silent';
+use DBIx::Class::Optional::Dependencies;
+use DBIx::Class::Schema::Loader::Utils qw/warnings_exist_silent sigwarn_silencer/;
 use Try::Tiny;
 use File::Path 'rmtree';
 use DBIx::Class::Schema::Loader 'make_schema_at';
@@ -31,6 +32,13 @@ my ($dsns, $common_version);
 for (qw/MSSQL MSSQL_ODBC MSSQL_ADO/) {
   next unless $ENV{"DBICTEST_${_}_DSN"};
 
+  (my $dep_group = lc "rdbms_$_") =~ s/mssql$/mssql_sybase/;
+  if (!DBIx::Class::Optional::Dependencies->req_ok_for($dep_group)) {
+      diag 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for($dep_group)
+          . " to test with $_";
+      next;
+  }
+
   $dsns->{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"};
   $dsns->{$_}{user} = $ENV{"DBICTEST_${_}_USER"};
   $dsns->{$_}{password} = $ENV{"DBICTEST_${_}_PASS"};
@@ -527,10 +535,9 @@ EOF
 
             SKIP: {
                 # for ADO
-                my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-                local $SIG{__WARN__} = sub {
-                    $warn_handler->(@_) unless $_[0] =~ /Changed database context/;
-                };
+                local $SIG{__WARN__} = sigwarn_silencer(
+                    qr/Changed database context/
+                );
 
                 my $dbh = $schema->storage->dbh;
 
@@ -758,10 +765,9 @@ sub cleanup_databases {
     return if $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP};
 
     # for ADO
-    my $warn_handler = $SIG{__WARN__} || sub { warn @_ };
-    local $SIG{__WARN__} = sub {
-        $warn_handler->(@_) unless $_[0] =~ /Changed database context/;
-    };
+    local $SIG{__WARN__} = sigwarn_silencer(
+        qr/Changed database context/
+    );
 
     my $dbh = $schema->storage->dbh;