Revert workarounds for $@ broken during 5.13.x - mainly 1f870d5a
[dbsrgits/DBIx-Class.git] / t / 749sqlanywhere.t
index 7189898..396e103 100644 (file)
@@ -5,16 +5,28 @@ use Test::More;
 use Test::Exception;
 use Scope::Guard ();
 use Try::Tiny;
+use DBIx::Class::Optional::Dependencies ();
 use lib qw(t/lib);
 use DBICTest;
 
+my ($dsn, $user, $pass)    = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" }      qw/DSN USER PASS/};
+my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/};
+
+plan skip_all => 'Test needs ' .
+  (join ' or ', map { $_ ? $_ : () }
+    DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere'),
+    DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere_odbc'))
+  unless
+    $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere')
+    or
+    $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_sqlanywhere_odbc')
+    or
+    (not $dsn || $dsn2);
+
 DBICTest::Schema->load_classes('ArtistGUID');
 
 # tests stolen from 748informix.t
 
-my ($dsn, $user, $pass)    = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" }      qw/DSN USER PASS/};
-my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/};
-
 plan skip_all => <<'EOF' unless $dsn || $dsn2;
 Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN},
 _USER and _PASS to run these tests
@@ -36,7 +48,7 @@ foreach my $info (@info) {
     auto_savepoint => 1
   });
 
-  my $guard = Scope::Guard->new(\&cleanup);
+  my $guard = Scope::Guard->new(sub{ cleanup($schema) });
 
   my $dbh = $schema->storage->dbh;
 
@@ -165,7 +177,7 @@ EOF
       ok($rs->find($id)->$type eq $binstr{$size}, "verified inserted $size $type" );
     }
   }
+
   my @uuid_types = qw/uniqueidentifier uniqueidentifierstr/;
 
 # test uniqueidentifiers (and the cursor_class).
@@ -247,6 +259,7 @@ SQL
 done_testing;
 
 sub cleanup {
+  my $schema = shift;
   eval { $schema->storage->dbh->do("DROP TABLE $_") }
     for qw/artist artist_guid bindtype_test/;
 }