List:Commits« Previous MessageNext Message »
From:jimw Date:March 19 2007 8:43pm
Subject:[svn:DBD-mysql] r9278 - DBD-mysql/trunk/t
View as plain text  
Author: jimw
Date: Mon Mar 19 12:43:20 2007
New Revision: 9278

Modified:
   DBD-mysql/trunk/t/40catalog.t
   DBD-mysql/trunk/t/multi_statement.t
   DBD-mysql/trunk/t/warnings.t

Log:
Fix tests that require post-4.0 features to get skipped when running against
earlier servers.


Modified: DBD-mysql/trunk/t/40catalog.t
==============================================================================
--- DBD-mysql/trunk/t/40catalog.t	(original)
+++ DBD-mysql/trunk/t/40catalog.t	Mon Mar 19 12:43:20 2007
@@ -4,6 +4,7 @@
 use Data::Dumper;
 use Test::More;
 use DBI;
+use DBI::Const::GetInfoType;
 use strict;
 $|= 1;
 
@@ -89,6 +90,9 @@
 # the server we are using for testing.
 #
 SKIP: {
+  skip "Server can't handle tricky table names", 33
+    if $dbh->get_info($GetInfoType{SQL_DBMS_VER}) lt "4.1";
+
   my $sth = $dbh->table_info("%", undef, undef, undef);
   is(scalar @{$sth->fetchall_arrayref()}, 0, "No catalogs expected");
 

Modified: DBD-mysql/trunk/t/multi_statement.t
==============================================================================
--- DBD-mysql/trunk/t/multi_statement.t	(original)
+++ DBD-mysql/trunk/t/multi_statement.t	Mon Mar 19 12:43:20 2007
@@ -3,6 +3,7 @@
 
 use Test::More tests => 7;
 use DBI;
+use DBI::Const::GetInfoType;
 use strict;
 $|= 1;
 
@@ -22,20 +23,25 @@
                         mysql_multi_statements => 1 });
 ok(defined $dbh, "Connected to database with multi statement support");
 
-ok($dbh->do("DROP TABLE IF EXISTS t1"), "clean up");
-ok($dbh->do("CREATE TABLE t1 (a INT)"), "create table");
+SKIP: {
+  skip "Server doesn't support multi statements", 6 
+    if $dbh->get_info($GetInfoType{SQL_DBMS_VER}) lt "4.1";
 
-ok($dbh->do("INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2);"));
+  ok($dbh->do("DROP TABLE IF EXISTS t1"), "clean up");
+  ok($dbh->do("CREATE TABLE t1 (a INT)"), "create table");
 
-$dbh->disconnect();
+  ok($dbh->do("INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2);"));
+
+  $dbh->disconnect();
 
-$dbh= DBI->connect($test_dsn, $test_user, $test_password,
-                   { RaiseError => 0, PrintError => 0, AutoCommit => 0,
-                     mysql_multi_statements => 0 });
-ok(defined $dbh, "Connected to database without multi statement support");
+  $dbh= DBI->connect($test_dsn, $test_user, $test_password,
+                     { RaiseError => 0, PrintError => 0, AutoCommit => 0,
+                       mysql_multi_statements => 0 });
+  ok(defined $dbh, "Connected to database without multi statement support");
 
-ok(not $dbh->do("INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2);"));
+  ok(not $dbh->do("INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2);"));
 
-ok($dbh->do("DROP TABLE IF EXISTS t1"), "clean up");
+  ok($dbh->do("DROP TABLE IF EXISTS t1"), "clean up");
+};
 
 $dbh->disconnect();

Modified: DBD-mysql/trunk/t/warnings.t
==============================================================================
--- DBD-mysql/trunk/t/warnings.t	(original)
+++ DBD-mysql/trunk/t/warnings.t	Mon Mar 19 12:43:20 2007
@@ -1,49 +1,36 @@
-#!/usr/bin/perl
+#!perl -w
+# vim: ft=perl
 
-use strict;
-use vars qw($test_dsn $test_user $test_password $mdriver $state);
+use Test::More tests => 4;
 use DBI;
-use Carp qw(croak);
-use Data::Dumper;
-
-$^W =1;
-
+use DBI::Const::GetInfoType;
+use strict;
+$|= 1;
 
-use DBI;
-$mdriver = "";
-my ($row, $sth, $dbh);
-foreach my $file ("lib.pl", "t/lib.pl", "DBD-mysql/t/lib.pl") {
-  do $file; if ($@) { print STDERR "Error while executing lib.pl: $@\n";
+my $mdriver= "";
+our ($test_dsn, $test_user, $test_password);
+foreach my $file ("lib.pl", "t/lib.pl") {
+  do $file;
+  if ($@) {
+    print STDERR "Error while executing $file: $@\n";
     exit 10;
   }
-  if ($mdriver ne '') {
-    last;
-  }
+  last if $mdriver ne '';
 }
 
-sub ServerError() {
-    print STDERR ("Cannot connect: ", $DBI::errstr, "\n",
-       "\tEither your server is not up and running or you have no\n",
-       "\tpermissions for acessing the DSN $test_dsn.\n",
-       "\tThis test requires a running server and write permissions.\n",
-       "\tPlease make sure your server is running and you have\n",
-       "\tpermissions, then retry.\n");
-    exit 10;
-}
-
-while(Testing())
-{
-  my ($sth);
-  Test($state or $dbh =
-    DBI->connect($test_dsn, $test_user, $test_password,
-  { RaiseError => 1, AutoCommit => 1})) or ServerError() ;
+my $dbh= DBI->connect($test_dsn, $test_user, $test_password,
+                      { RaiseError => 1, PrintError => 1, AutoCommit => 0});
+ok(defined $dbh, "Connected to database");
+
+SKIP: {
+  skip "Server doesn't report warnings", 3
+    if $dbh->get_info($GetInfoType{SQL_DBMS_VER}) lt "4.1";
+
+  my $sth;
+  ok($sth= $dbh->prepare("DROP TABLE IF EXISTS no_such_table"));
+  ok($sth->execute());
 
-  Test($state or $sth = $dbh->prepare("drop table if exists no_such_table")) or
-    DbiError($dbh->err, $dbh->errstr);
+  is($sth->{mysql_warning_count}, 1);
+};
 
-  Test($state or $sth->execute()) or
-    DbiError($dbh->err, $dbh->errstr);
-
-  Test($state or $sth->{mysql_warning_count} == 1) or
-    DbiError($dbh->err, $dbh->errstr);
-}
+$dbh->disconnect;
Thread
[svn:DBD-mysql] r9278 - DBD-mysql/trunk/tjimw20 Mar