From: Rafael Kitover Date: Sun, 3 Jul 2011 17:03:19 +0000 (-0400) Subject: check database driver dependencies for tests X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=199fbc453ec03891d0e156d7353c5e992ba4de47;p=dbsrgits%2FDBIx-Class-Historic.git check database driver dependencies for tests --- diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index e4988e8..5e63d7b 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -76,6 +76,24 @@ my $rdbms_ase = { my $rdbms_db2 = { 'DBD::DB2' => '0', }; +my $rdbms_db2_400 = { + 'DBD::ODBC' => '0', +}; +my $rdbms_informix = { + 'DBD::Informix' => '0', +}; +my $rdbms_sqlanywhere = { + 'DBD::SQLAnywhere' => '0', +}; +my $rdbms_sqlanywhere_odbc = { + 'DBD::ODBC' => '0', +}; +my $rdbms_firebird = { + 'DBD::Firebird' => '0', +}; +my $rdbms_firebird_interbase = { + 'DBD::InterBase' => '0', +}; my $rdbms_firebird_odbc = { 'DBD::ODBC' => '0', }; @@ -334,6 +352,76 @@ my $reqs = { }, }, + rdbms_db2_400 => { + req => { + %$rdbms_db2_400, + }, + pod => { + title => 'DB2 on AS/400 support', + desc => 'Modules required to connect to DB2 on AS/400', + }, + }, + + rdbms_informix => { + req => { + %$rdbms_informix, + }, + pod => { + title => 'Informix support', + desc => 'Modules required to connect to Informix', + }, + }, + + rdbms_sqlanywhere => { + req => { + %$rdbms_sqlanywhere, + }, + pod => { + title => 'SQLAnywhere support', + desc => 'Modules required to connect to SQLAnywhere', + }, + }, + + rdbms_sqlanywhere_odbc => { + req => { + %$rdbms_sqlanywhere_odbc, + }, + pod => { + title => 'SQLAnywhere support via DBD::ODBC', + desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC', + }, + }, + + rdbms_firebird => { + req => { + %$rdbms_firebird, + }, + pod => { + title => 'Firebird support', + desc => 'Modules required to connect to Firebird', + }, + }, + + rdbms_firebird_interbase => { + req => { + %$rdbms_firebird_interbase, + }, + pod => { + title => 'Firebird support via DBD::InterBase', + desc => 'Modules required to connect to Firebird via DBD::InterBase', + }, + }, + + rdbms_firebird_odbc => { + req => { + %$rdbms_firebird_odbc, + }, + pod => { + title => 'Firebird support via DBD::ODBC', + desc => 'Modules required to connect to Firebird via DBD::ODBC', + }, + }, + # the order does matter because the rdbms support group might require # a different version that the test group test_rdbms_pg => { @@ -434,6 +522,60 @@ my $reqs = { }, }, + test_rdbms_db2_400 => { + req => { + $ENV{DBICTEST_DB2_400_DSN} + ? ( + %$rdbms_db2_400, + ) : () + }, + }, + + test_rdbms_informix => { + req => { + $ENV{DBICTEST_INFORMIX_DSN} + ? ( + %$rdbms_informix, + ) : () + }, + }, + + test_rdbms_sqlanywhere => { + req => { + $ENV{DBICTEST_SQLANYWHERE_DSN} + ? ( + %$rdbms_sqlanywhere, + ) : () + }, + }, + + test_rdbms_sqlanywhere_odbc => { + req => { + $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN} + ? ( + %$rdbms_sqlanywhere_odbc, + ) : () + }, + }, + + test_rdbms_firebird => { + req => { + $ENV{DBICTEST_FIREBIRD_DSN} + ? ( + %$rdbms_firebird, + ) : () + }, + }, + + test_rdbms_firebird_interbase => { + req => { + $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN} + ? ( + %$rdbms_firebird_interbase, + ) : () + }, + }, + test_rdbms_firebird_odbc => { req => { $ENV{DBICTEST_FIREBIRD_ODBC_DSN} @@ -520,7 +662,6 @@ sub _check_deps { if (keys %errors) { my $missing = join (', ', map { $deps->{$_} ? "$_ >= $deps->{$_}" : $_ } (sort keys %errors) ); $missing .= " (see $class for details)" if $reqs->{$group}{pod}; - $missing .= "\n"; $res = { status => 0, errorlist => \%errors, diff --git a/t/50fork.t b/t/50fork.t index 40d8655..c5384c9 100644 --- a/t/50fork.t +++ b/t/50fork.t @@ -1,6 +1,10 @@ use strict; use warnings; use Test::More; +use DBIx::Class::Optional::Dependencies (); + +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; diff --git a/t/51threads.t b/t/51threads.t index fb7cf10..a9d842b 100644 --- a/t/51threads.t +++ b/t/51threads.t @@ -16,8 +16,12 @@ BEGIN { use threads; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); diff --git a/t/51threadtxn.t b/t/51threadtxn.t index 65220b6..7b11a7b 100644 --- a/t/51threadtxn.t +++ b/t/51threadtxn.t @@ -18,8 +18,12 @@ BEGIN { use threads; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); diff --git a/t/71mysql.t b/t/71mysql.t index c624913..f78948c 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -6,11 +6,15 @@ use Test::Exception; use DBI::Const::GetInfoType; use Scalar::Util qw/weaken/; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use DBIC::SqlMakerTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; diff --git a/t/72pg.t b/t/72pg.t index 1f7312b..5596fd2 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -4,9 +4,12 @@ use warnings; use Test::More; use Test::Exception; use Sub::Name; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_pg'); my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; diff --git a/t/72pg_bytea.t b/t/72pg_bytea.t index d507a6d..0468976 100644 --- a/t/72pg_bytea.t +++ b/t/72pg_bytea.t @@ -2,9 +2,13 @@ use strict; use warnings; use Test::More; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); + my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' diff --git a/t/73oracle.t b/t/73oracle.t index 1d7d03f..aafd1f0 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -5,6 +5,7 @@ use Test::Exception; use Test::More; use Sub::Name; use Try::Tiny; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; diff --git a/t/73oracle_hq.t b/t/73oracle_hq.t index 6759ded..d9ef26b 100644 --- a/t/73oracle_hq.t +++ b/t/73oracle_hq.t @@ -3,7 +3,7 @@ use warnings; use Test::Exception; use Test::More; - +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBIC::SqlMakerTest; @@ -15,8 +15,8 @@ $ENV{NLS_SORT} = "BINARY"; $ENV{NLS_COMP} = "BINARY"; $ENV{NLS_LANG} = "AMERICAN"; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_oracle') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_oracle'); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_oracle') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_oracle'); my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; diff --git a/t/745db2.t b/t/745db2.t index 0299816..90576d0 100644 --- a/t/745db2.t +++ b/t/745db2.t @@ -4,9 +4,13 @@ use warnings; use Test::More; use Test::Exception; use Try::Tiny; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_db2') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_db2'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; diff --git a/t/746db2_400.t b/t/746db2_400.t index 29b7ff1..29d16e1 100644 --- a/t/746db2_400.t +++ b/t/746db2_400.t @@ -2,9 +2,13 @@ use strict; use warnings; use Test::More; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_db2_400') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_db2_400'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; diff --git a/t/746mssql.t b/t/746mssql.t index ac16bc8..36a405f 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -3,12 +3,16 @@ use warnings; use Test::More; use Test::Exception; +use Try::Tiny; +use DBIx::Class::SQLMaker::LimitDialects; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use DBIC::SqlMakerTest; -use Try::Tiny; -use DBIx::Class::SQLMaker::LimitDialects; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mssql_odbc') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mssql_odbc'); + my $OFFSET = DBIx::Class::SQLMaker::LimitDialects->__offset_bindtype; my $TOTAL = DBIx::Class::SQLMaker::LimitDialects->__total_bindtype; diff --git a/t/746sybase.t b/t/746sybase.t index 8cf7e14..7fcffb4 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -4,9 +4,13 @@ no warnings 'uninitialized'; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +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/}; my $TESTS = 66 + 2; diff --git a/t/747mssql_ado.t b/t/747mssql_ado.t index 3c276ef..a2f99d5 100644 --- a/t/747mssql_ado.t +++ b/t/747mssql_ado.t @@ -3,9 +3,13 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mssql_ado') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mssql_ado'); + # Example DSN (from frew): # dbi:ADO:PROVIDER=sqlncli10;SERVER=tcp:172.24.2.10;MARS Connection=True;Initial Catalog=CIS;UID=cis_web;PWD=...;DataTypeCompatibility=80; diff --git a/t/748informix.t b/t/748informix.t index 8ddb01a..ad21c2e 100644 --- a/t/748informix.t +++ b/t/748informix.t @@ -3,9 +3,13 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_informix') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_informix'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_INFORMIX_${_}" } qw/DSN USER PASS/}; #warn "$dsn $user $pass"; diff --git a/t/749sqlanywhere.t b/t/749sqlanywhere.t index 7189898..816186e 100644 --- a/t/749sqlanywhere.t +++ b/t/749sqlanywhere.t @@ -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 diff --git a/t/74mssql.t b/t/74mssql.t index 57d7c69..2470c7f 100644 --- a/t/74mssql.t +++ b/t/74mssql.t @@ -10,9 +10,13 @@ BEGIN { use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mssql_sybase') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mssql_sybase'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' diff --git a/t/750firebird.t b/t/750firebird.t index 86cb433..1b4166d 100644 --- a/t/750firebird.t +++ b/t/750firebird.t @@ -3,24 +3,41 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use Scope::Guard (); -# tests stolen from 749sybase_asa.t +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_FIREBIRD_${_}" } qw/DSN USER PASS/}; +my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_FIREBIRD_INTERBASE_${_}" } qw/DSN USER PASS/}; +my ($dsn3, $user3, $pass3) = @ENV{map { "DBICTEST_FIREBIRD_ODBC_${_}" } qw/DSN USER PASS/}; + +plan skip_all => 'Test needs ' . + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_firebird'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_firebird_interbase'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_firebird_odbc')) + unless + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_firebird') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_firebird_interbase') + or + $dsn3 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_firebird_odbc') + or + (not $dsn || $dsn2 || $dsn3); -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_FIREBIRD_${_}" } qw/DSN USER PASS/}; -my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_FIREBIRD_ODBC_${_}" } qw/DSN USER PASS/}; +# tests stolen from 749sybase_asa.t # Example DSNs: -# dbi:InterBase:db=/var/lib/firebird/2.5/data/hlaghdb.fdb # dbi:Firebird:db=/var/lib/firebird/2.5/data/hlaghdb.fdb +# dbi:InterBase:db=/var/lib/firebird/2.5/data/hlaghdb.fdb # Example ODBC DSN: # dbi:ODBC:Driver=Firebird;Dbname=/var/lib/firebird/2.5/data/hlaghdb.fdb -plan skip_all => <<'EOF' unless $dsn || $dsn2; -Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN}, +plan skip_all => <<'EOF' unless $dsn || $dsn2 || $dsn3; +Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN} +and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN}, _USER and _PASS to run these tests. WARNING: this test creates and drops the tables "artist", "bindtype_test" and @@ -31,6 +48,7 @@ EOF my @info = ( [ $dsn, $user, $pass ], [ $dsn2, $user2, $pass2 ], + [ $dsn3, $user3, $pass3 ], ); my $schema; diff --git a/t/751msaccess.t b/t/751msaccess.t index 27eeac9..403dc21 100644 --- a/t/751msaccess.t +++ b/t/751msaccess.t @@ -5,11 +5,26 @@ use Test::More; use Test::Exception; use Scope::Guard (); use Try::Tiny; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use DBIC::DebugObj (); use DBIC::SqlMakerTest; +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSACCESS_ODBC_${_}" } qw/DSN USER PASS/}; +my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/}; + +plan skip_all => 'Test needs ' . + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_odbc'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_ado')) + unless + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_odbc') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_ado') + or + (not $dsn || $dsn2); + DBICTest::Schema->load_classes('ArtistGUID'); # Example DSNs (32bit only): @@ -17,23 +32,11 @@ DBICTest::Schema->load_classes('ArtistGUID'); # dbi:ADO:Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\rkitover\Documents\access_sample.accdb # dbi:ADO:Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\rkitover\Documents\access_sample.accdb;Persist Security Info=False' -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSACCESS_ODBC_${_}" } qw/DSN USER PASS/}; -my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/}; - plan skip_all => <<'EOF' unless $dsn || $dsn2; Set $ENV{DBICTEST_MSACCESS_ODBC_DSN} and/or $ENV{DBICTEST_MSACCESS_ADO_DSN} (and optionally _USER and _PASS) to run these tests. Warning: this test drops and creates the tables 'artist', 'cd', 'bindtype_test' and 'artist_guid'. EOF -plan skip_all => 'Test needs ' . -DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_odbc') -. ' or ' . -DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_ado') - unless - DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_odbc') - or - DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_ado'); - my @info = ( [ $dsn, $user || '', $pass || '' ], [ $dsn2, $user2 || '', $pass2 || '' ], diff --git a/t/98savepoints.t b/t/98savepoints.t index 45fe577..7bc6d64 100644 --- a/t/98savepoints.t +++ b/t/98savepoints.t @@ -2,14 +2,21 @@ use strict; use warnings; use Test::More; +use DBIx::Class::Optional::Dependencies (); my ($create_sql, $dsn, $user, $pass); if ($ENV{DBICTEST_PG_DSN}) { + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); + ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; $create_sql = "CREATE TABLE artist (artistid serial PRIMARY KEY, name VARCHAR(100), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10))"; } elsif ($ENV{DBICTEST_MYSQL_DSN}) { + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql'); + ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; $create_sql = "CREATE TABLE artist (artistid INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), rank INTEGER NOT NULL DEFAULT '13', charfield CHAR(10)) ENGINE=InnoDB"; diff --git a/t/inflate/datetime_firebird.t b/t/inflate/datetime_firebird.t index 0f62161..613dfe3 100644 --- a/t/inflate/datetime_firebird.t +++ b/t/inflate/datetime_firebird.t @@ -3,27 +3,44 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use Scope::Guard (); my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_FIREBIRD_${_}" } qw/DSN USER PASS/}; -my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_FIREBIRD_ODBC_${_}" } qw/DSN USER PASS/}; +my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_FIREBIRD_INTERBASE_${_}" } qw/DSN USER PASS/}; +my ($dsn3, $user3, $pass3) = @ENV{map { "DBICTEST_FIREBIRD_ODBC_${_}" } qw/DSN USER PASS/}; + +plan skip_all => 'Test needs ' . + (join ' and ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_firebird'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_firebird_interbase'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_firebird_odbc'))) + unless + DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && ( + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_firebird') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_firebird_interbase') + or + $dsn3 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_firebird_odbc')) + or (not $dsn || $dsn2 || $dsn3); if (not ($dsn || $dsn2)) { plan skip_all => <<'EOF'; -Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN} +Set $ENV{DBICTEST_FIREBIRD_DSN} and/or $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN} +and/or $ENV{DBICTEST_FIREBIRD_ODBC_DSN} _USER and _PASS to run this test'. Warning: This test drops and creates a table called 'event'"; EOF } -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); - my @info = ( [ $dsn, $user, $pass ], [ $dsn2, $user2, $pass2 ], + [ $dsn3, $user3, $pass3 ], ); my $schema; diff --git a/t/inflate/datetime_informix.t b/t/inflate/datetime_informix.t index da0cb69..5746f25 100644 --- a/t/inflate/datetime_informix.t +++ b/t/inflate/datetime_informix.t @@ -3,10 +3,17 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use Scope::Guard (); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') +. ' and ' . +DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_informix') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') + && DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_informix'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_INFORMIX_${_}" } qw/DSN USER PASS/}; if (not $dsn) { @@ -16,9 +23,6 @@ Warning: This test drops and creates a table called 'event'"; EOF } -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); - my $schema; { diff --git a/t/inflate/datetime_msaccess.t b/t/inflate/datetime_msaccess.t index 834417a..fdd2284 100644 --- a/t/inflate/datetime_msaccess.t +++ b/t/inflate/datetime_msaccess.t @@ -5,20 +5,31 @@ 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_MSACCESS_ODBC_${_}" } qw/DSN USER PASS/}; my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/}; +plan skip_all => 'Test needs ' . + (join ' and ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_odbc'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_ado'))) + unless + DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && ( + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_odbc') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_ado')) + or (not $dsn || $dsn2); + plan skip_all => <<'EOF' unless $dsn || $dsn2; Set $ENV{DBICTEST_MSACCESS_ODBC_DSN} and/or $ENV{DBICTEST_MSACCESS_ADO_DSN} (and optionally _USER and _PASS) to run these tests. Warning: this test drops and creates the table 'track'. EOF -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); - my @connect_info = ( [ $dsn, $user || '', $pass || '' ], [ $dsn2, $user2 || '', $pass2 || '' ], diff --git a/t/inflate/datetime_mssql.t b/t/inflate/datetime_mssql.t index cff0fba..822cc84 100644 --- a/t/inflate/datetime_mssql.t +++ b/t/inflate/datetime_mssql.t @@ -5,10 +5,29 @@ use Test::More; use Test::Exception; use Scope::Guard (); use Try::Tiny; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -DBICTest::Schema->load_classes('EventSmallDT'); +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/}; +my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; +my ($dsn3, $user3, $pass3) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" } qw/DSN USER PASS/}; + +plan skip_all => 'Test needs ' . + (join ' and ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), + (join ' or ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_mssql_odbc'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_mssql_sybase'), + DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_mssql_ado'))) + unless + DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && ( + $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mssql_odbc') + or + $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mssql_sybase') + or + $dsn3 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mssql_ado')) + or (not $dsn || $dsn2 || $dsn3); # use this if you keep a copy of DBD::Sybase linked to FreeTDS somewhere else BEGIN { @@ -17,10 +36,6 @@ BEGIN { } } -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/}; -my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; -my ($dsn3, $user3, $pass3) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" } qw/DSN USER PASS/}; - if (not ($dsn || $dsn2 || $dsn3)) { plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN} and/or $ENV{DBICTEST_MSSQL_DSN} and/or ' @@ -29,8 +44,7 @@ if (not ($dsn || $dsn2 || $dsn3)) { ." 'track'."; } -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); +DBICTest::Schema->load_classes('EventSmallDT'); my @connect_info = ( [ $dsn, $user, $pass ], diff --git a/t/inflate/datetime_mysql.t b/t/inflate/datetime_mysql.t index d14ee7d..a810810 100644 --- a/t/inflate/datetime_mysql.t +++ b/t/inflate/datetime_mysql.t @@ -4,6 +4,7 @@ use warnings; use Test::More; use Test::Exception; use Test::Warn; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use DBICTest::Schema; diff --git a/t/inflate/datetime_oracle.t b/t/inflate/datetime_oracle.t index c6c1324..af8c90b 100644 --- a/t/inflate/datetime_oracle.t +++ b/t/inflate/datetime_oracle.t @@ -3,9 +3,13 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_oracle') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_oracle'); + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; if (not ($dsn && $user && $pass)) { @@ -13,9 +17,6 @@ if (not ($dsn && $user && $pass)) { 'Warning: This test drops and creates a table called \'track\''; } -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_oracle') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_oracle'); - # DateTime::Format::Oracle needs this set $ENV{NLS_DATE_FORMAT} = 'DD-MON-YY'; $ENV{NLS_TIMESTAMP_FORMAT} = 'YYYY-MM-DD HH24:MI:SSXFF'; diff --git a/t/inflate/datetime_pg.t b/t/inflate/datetime_pg.t index 62eb810..0751561 100644 --- a/t/inflate/datetime_pg.t +++ b/t/inflate/datetime_pg.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use Test::Warn; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; diff --git a/t/inflate/datetime_sqlanywhere.t b/t/inflate/datetime_sqlanywhere.t index 5b5b866..6788f87 100644 --- a/t/inflate/datetime_sqlanywhere.t +++ b/t/inflate/datetime_sqlanywhere.t @@ -4,12 +4,26 @@ use warnings; use Test::More; use Test::Exception; use Scope::Guard (); +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 ' and ', map { $_ ? $_ : () } + DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), + (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 + DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') && ( + $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); + if (not ($dsn || $dsn2)) { plan skip_all => <<'EOF'; Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN} @@ -18,9 +32,6 @@ Warning: This test drops and creates a table called 'event'"; EOF } -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); - my @info = ( [ $dsn, $user, $pass ], [ $dsn2, $user2, $pass2 ], diff --git a/t/inflate/datetime_sybase.t b/t/inflate/datetime_sybase.t index afd7ef4..56c0648 100644 --- a/t/inflate/datetime_sybase.t +++ b/t/inflate/datetime_sybase.t @@ -5,23 +5,26 @@ use Test::More; use Test::Exception; use Scope::Guard (); use Try::Tiny; +use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -DBICTest::Schema->load_classes('EventSmallDT'); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') +. ' and ' . +DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_ase') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') + && DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_ase'); my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}; 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 a table called 'track'"; + "\nWarning: This test drops and creates a table called 'track' and " . + "'event_small_dt'"; } -for (qw/test_rdbms_ase test_dt/) { - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ($_) - unless DBIx::Class::Optional::Dependencies->req_ok_for ($_); -} +DBICTest::Schema->load_classes('EventSmallDT'); my @storage_types = ( 'DBI::Sybase::ASE', diff --git a/t/storage/global_destruction.t b/t/storage/global_destruction.t index 79bcdee..629f7b7 100644 --- a/t/storage/global_destruction.t +++ b/t/storage/global_destruction.t @@ -4,6 +4,8 @@ use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies (); + use lib qw(t/lib); use DBICTest; @@ -13,6 +15,15 @@ for my $type (qw/PG MYSQL/) { skip "Skipping $type tests without DBICTEST_${type}_DSN", 1 unless $ENV{"DBICTEST_${type}_DSN"}; + if ($type eq 'PG') { + skip "skipping Pg tests without dependencies installed", 1 + unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_pg'); + } + elsif ($type eq 'MYSQL') { + skip "skipping MySQL tests without dependencies installed", 1 + unless DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_mysql'); + } + my $schema = DBICTest::Schema->connect (@ENV{map { "DBICTEST_${type}_${_}" } qw/DSN USER PASS/}); # emulate a singleton-factory, just cache the object *somewhere in a different package* diff --git a/t/storage/quote_names.t b/t/storage/quote_names.t index f77c3de..4d768cf 100644 --- a/t/storage/quote_names.t +++ b/t/storage/quote_names.t @@ -3,6 +3,7 @@ use warnings; use Test::More; use Test::Exception; use Data::Dumper::Concise; +use Try::Tiny; use lib qw(t/lib); use DBICTest; @@ -103,9 +104,15 @@ while (my ($db, $base_class) = each %dbs) { next unless $dsn; - my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { - quote_names => 1 - }); + my $schema; + + try { + $schema = DBICTest::Schema->connect($dsn, $user, $pass, { + quote_names => 1 + }); + $schema->storage->ensure_connected; + 1; + } || next; my $expected_quote_char = $expected{$base_class}{quote_char}; my $quote_char_text = dumper($expected_quote_char);