Fix ASE bulk_insert for bind changes in 0e773352
[dbsrgits/DBIx-Class.git] / t / 746sybase.t
index b82138b..6a4b4ef 100644 (file)
@@ -8,20 +8,39 @@ use DBIx::Class::Optional::Dependencies ();
 use lib qw(t/lib);
 use DBICTest;
 
+my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
+if (not ($dsn && $user)) {
+  plan skip_all => join ' ',
+    'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test.',
+    'Warning: This test drops and creates the tables:',
+    "'artist', 'money_test' and 'bindtype_test'",
+  ;
+};
+
 plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_ase')
   unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_ase');
 
-my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/};
+# first run the test without the lang variable set
+# it is important to do this before module load, hence
+# the subprocess before the optdep check
+if ($ENV{LANG} and $ENV{LANG} ne 'C') {
+  my $oldlang = $ENV{LANG};
+  local $ENV{LANG} = 'C';
 
-my $TESTS = 66 + 2;
+  pass ("Your lang is set to $oldlang - testing with C first");
 
-if (not ($dsn && $user)) {
-  plan skip_all =>
-    'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test' .
-    "\nWarning: This test drops and creates the tables " .
-    "'artist', 'money_test' and 'bindtype_test'";
-} else {
-  plan tests => $TESTS*2 + 1;
+  my @cmd = ($^X, __FILE__);
+
+  # this is cheating, and may even hang here and there (testing on windows passed fine)
+  # will be replaced with Test::SubExec::Noninteractive in due course
+  require IPC::Open2;
+  IPC::Open2::open2(my $out, my $in, @cmd);
+  while (my $ln = <$out>) {
+    print "   $ln";
+  }
+
+  wait;
+  ok (! $?, "Wstat $? from: @cmd");
 }
 
 my @storage_types = (
@@ -63,9 +82,8 @@ for my $storage_type (@storage_types) {
 
   if ($storage_idx == 0 &&
       $schema->storage->isa('DBIx::Class::Storage::DBI::Sybase::ASE::NoBindVars')) {
-# no placeholders in this version of Sybase or DBD::Sybase (or using FreeTDS)
-      my $tb = Test::More->builder;
-      $tb->skip('no placeholders') for 1..$TESTS;
+      # no placeholders in this version of Sybase or DBD::Sybase (or using FreeTDS)
+      skip "Skipping entire test for $storage_type - no placeholder support", 1;
       next;
   }
 
@@ -612,6 +630,8 @@ SQL
 
 is $ping_count, 0, 'no pings';
 
+done_testing;
+
 # clean up our mess
 END {
   if (my $dbh = eval { $schema->storage->_dbh }) {