From 8ccc7518f5fd8c8bc0964b6ba61d60757b3b09e7 Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Thu, 20 Jul 2006 15:54:14 +0000 Subject: [PATCH] fixed mysql test in db_colinfo to skip if no MySQL DBD driver git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@514 48953598-375a-da11-a14b-00016c27c3ee --- META.yml | 4 ++-- lib/Maypole.pm | 2 +- t/db_colinfo.t | 32 ++++++++++++++++++-------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/META.yml b/META.yml index 2cae870..2a9b00d 100644 --- a/META.yml +++ b/META.yml @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: Maypole -version: 2.11_pre4 +version: 2.11_pre5 version_from: lib/Maypole.pm installdirs: site requires: @@ -16,7 +16,7 @@ requires: Class::DBI::Pager: 0 Class::DBI::Plugin::RetrieveAll: 0 Class::DBI::Plugin::Type: 0 - Class::DBI::SQLite: 0 + Class::DBI::SQLite: 0.08 Digest::MD5: 0 File::MMagic::XS: 0.08 HTML::Element: 0 diff --git a/lib/Maypole.pm b/lib/Maypole.pm index 03205a6..35347ad 100644 --- a/lib/Maypole.pm +++ b/lib/Maypole.pm @@ -12,7 +12,7 @@ use URI::QueryParam; use NEXT; use File::MMagic::XS qw(:compat); -our $VERSION = '2.11_pre4'; +our $VERSION = '2.11_pre5'; our $mmagic = File::MMagic::XS->new(); # proposed privacy conventions: diff --git a/t/db_colinfo.t b/t/db_colinfo.t index 471d059..c56fbf2 100755 --- a/t/db_colinfo.t +++ b/t/db_colinfo.t @@ -88,24 +88,28 @@ package main; $DB_Class = 'BeerDB::BeerTestmysql'; -my $drh = DBI->install_driver("mysql"); -my %databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs'); +my $drh = eval { DBI->install_driver("mysql"); }; +$err = $@; +if ($err) { + $skip_msg = "no driver for MySQL"; +} else { + my %databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs'); -unless ($databases{test}) { - my $rc = $drh->func("createdb", 'test', 'admin'); -} + unless ($databases{test}) { + my $rc = $drh->func("createdb", 'test', 'admin'); + } -%databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs'); + %databases = map { $_ => 1 } $drh->func('localhost', 3306, '_ListDBs'); -if ($databases{test}) { - eval {$DB_Class->connection("dbi:mysql:$db", "$dbuser", "$dbpasswd"); }; - $err = $@; - $skip_msg = "Could not connect to MySQL using database 'test', username 'test', and password ''. Check privileges and try again."; -} else { - $err = 'no test db'; - $skip_msg = "Could not connect to MySQL using database 'test' as it doesn't exist, sorry"; + if ($databases{test}) { + eval {$DB_Class->connection("dbi:mysql:$db", "$dbuser", "$dbpasswd"); }; + $err = $@; + $skip_msg = "Could not connect to MySQL using database 'test', username 'test', and password ''. Check privileges and try again."; + } else { + $err = 'no test db'; + $skip_msg = "Could not connect to MySQL using database 'test' as it doesn't exist, sorry"; + } } - $skip_howmany = 22; SKIP: { -- 2.39.5