X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fcdbi%2Ftestlib%2FMyBase.pm;h=1fc77d0e752ef12ec045d9c0b1fef1702f2c59fc;hb=961d79dbe25ef8a92e867fcc84914b4bf568c11d;hp=aab76fe6e42c64706da3ba2e5c4fa9ed2717fe02;hpb=6a3bf2519832866d037740c5fb22341dad6f8bb3;p=dbsrgits%2FDBIx-Class.git diff --git a/t/cdbi/testlib/MyBase.pm b/t/cdbi/testlib/MyBase.pm index aab76fe..1fc77d0 100644 --- a/t/cdbi/testlib/MyBase.pm +++ b/t/cdbi/testlib/MyBase.pm @@ -1,18 +1,49 @@ package # hide from PAUSE MyBase; +use warnings; use strict; -use base qw(DBIx::Class::CDBICompat); use DBI; -use vars qw/$dbh/; +use lib 't/lib'; +use DBICTest; + +use base qw(DBIx::Class::CDBICompat); + +our $dbh; + +my $err; +if (! $ENV{DBICTEST_MYSQL_DSN} ) { + $err = 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'; +} +elsif ( ! DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql') ) { + $err = 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') +} + +if ($err) { + my $t = eval { Test::Builder->new }; + if ($t and ! $t->current_test) { + $t->skip_all ($err); + } + else { + die "$err\n"; + } +} my @connect = (@ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}, { PrintError => 0}); +# this is only so we grab a lock on mysql +{ + my $x = DBICTest::Schema->connect(@connect); +} + $dbh = DBI->connect(@connect) or die DBI->errstr; my @table; -END { $dbh->do("DROP TABLE $_") foreach @table } +END { + $dbh->do("DROP TABLE $_") for @table; + undef $dbh; +} __PACKAGE__->connection(@connect);