From: Peter Rabbitson Date: Fri, 3 Feb 2012 11:07:40 +0000 (+0100) Subject: More test cleanups, in the spirit of 49b3a2641 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=72d94b6be76602ae9545385f034d5c6f8cb4d284;p=dbsrgits%2FDBIx-Class-Historic.git More test cleanups, in the spirit of 49b3a2641 Deliberatey not fixing up everything under the same consistency umbrella: some of the tests can not be currently executed (lack of pre-set RDBMS), and moreover there are additional pieces missing to make this fully "clean" Just merging outstanding work from some time ago, to make subsequent commits easier to apply --- diff --git a/t/50fork.t b/t/50fork.t index af61dca..3d2c00f 100644 --- a/t/50fork.t +++ b/t/50fork.t @@ -7,16 +7,17 @@ use lib qw(t/lib); use DBICTest; use DBIx::Class::Optional::Dependencies (); +# set early - used in END my $main_pid = $$; -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); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); + # README: If you set the env var to a number greater than 10, # we will use that many children my $num_children = $ENV{DBICTEST_FORK_STRESS} || 1; diff --git a/t/51threadnodb.t b/t/51threadnodb.t index 95c9aaf..7b37c4f 100644 --- a/t/51threadnodb.t +++ b/t/51threadnodb.t @@ -1,32 +1,38 @@ +# README: If you set the env var DBICTEST_THREAD_STRESS to a number greater +# than 10, we will use that many children + +use strict; +use warnings; use Config; + BEGIN { - unless ($Config{useithreads}) { - print "1..0 # SKIP your perl does not support ithreads\n"; - exit 0; + my $err; + + if (! $Config{useithreads}) { + $err = 'your perl does not support ithreads'; + } + elsif ($] < '5.008005') { + $err = 'DBIC does not actively support threads before perl 5.8.5'; + } + elsif ($INC{'Devel/Cover.pm'}) { + $err = 'Devel::Cover does not work with threads yet'; } - if ($INC{'Devel/Cover.pm'}) { - print "1..0 # SKIP Devel::Cover does not work with threads yet\n"; + if ($err) { + print "1..0 # SKIP $err\n"; exit 0; } } -use threads; -use strict; -use warnings; +use threads; # must be loaded before Test::More use Test::More; use lib qw(t/lib); use DBICTest; -plan skip_all => 'DBIC does not actively support threads before perl 5.8.5' - if $] < '5.008005'; - plan skip_all => 'Potential problems on Win32 Perl < 5.14 and Variable::Magic - investigation pending' if $^O eq 'MSWin32' && $] < 5.014 && DBICTest::RunMode->is_plain; -# README: If you set the env var to a number greater than 10, -# we will use that many children my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1; if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; diff --git a/t/51threads.t b/t/51threads.t index 382458d..3e2061c 100644 --- a/t/51threads.t +++ b/t/51threads.t @@ -1,46 +1,49 @@ +# README: If you set the env var DBICTEST_THREAD_STRESS to a number greater +# than 10, we will use that many children + +use strict; +use warnings; use Config; + BEGIN { - unless ($Config{useithreads}) { - print "1..0 # SKIP your perl does not support ithreads\n"; - exit 0; + my $err; + + if (! $Config{useithreads}) { + $err = 'your perl does not support ithreads'; + } + elsif ($] < '5.008005') { + $err = 'DBIC does not actively support threads before perl 5.8.5'; + } + elsif ($INC{'Devel/Cover.pm'}) { + $err = 'Devel::Cover does not work with threads yet'; } - if ($INC{'Devel/Cover.pm'}) { - print "1..0 # SKIP Devel::Cover does not work with threads yet\n"; + if ($err) { + print "1..0 # SKIP $err\n"; exit 0; } } -use threads; - -use strict; -use warnings; +use threads; # must be loaded before Test::More use Test::More; use Test::Exception; -plan skip_all => 'DBIC does not actively support threads before perl 5.8.5' - if $] < '5.008005'; - 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, $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); -# README: If you set the env var to a number greater than 10, -# we will use that many children +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 $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1; if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; } -use_ok('DBICTest::Schema'); - my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 }); my $parent_rs; diff --git a/t/51threadtxn.t b/t/51threadtxn.t index a0e07bd..2463628 100644 --- a/t/51threadtxn.t +++ b/t/51threadtxn.t @@ -1,28 +1,32 @@ -# README: If you set the env var to a number greater than 10, -# we will use that many children +# README: If you set the env var DBICTEST_THREAD_STRESS to a number greater +# than 10, we will use that many children +use strict; +use warnings; use Config; + BEGIN { - unless ($Config{useithreads}) { - print "1..0 # SKIP your perl does not support ithreads\n"; - exit 0; + my $err; + + if (! $Config{useithreads}) { + $err = 'your perl does not support ithreads'; + } + elsif ($] < '5.008005') { + $err = 'DBIC does not actively support threads before perl 5.8.5'; + } + elsif ($INC{'Devel/Cover.pm'}) { + $err = 'Devel::Cover does not work with threads yet'; } - if ($INC{'Devel/Cover.pm'}) { - print "1..0 # SKIP Devel::Cover does not work with threads yet\n"; + if ($err) { + print "1..0 # SKIP $err\n"; exit 0; } } -use threads; - -use strict; -use warnings; +use threads; # must be loaded before Test::More use Test::More; -plan skip_all => 'DBIC does not actively support threads before perl 5.8.5' - if $] < '5.008005'; - use DBIx::Class::Optional::Dependencies (); use Scalar::Util 'weaken'; use lib qw(t/lib); @@ -35,13 +39,13 @@ plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); +# README: If you set the env var DBICTEST_THREAD_STRESS to a number greater +# than 10, we will use that many children my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1; if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; } -use_ok('DBICTest::Schema'); - my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 }); my $parent_rs; diff --git a/t/71mysql.t b/t/71mysql.t index 2f99ff5..c5f7532 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -12,14 +12,14 @@ 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_mysql') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql'); - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); +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 $schema = DBICTest::Schema->connect($dsn, $user, $pass, { quote_names => 1 }); my $dbh = $schema->storage->dbh; diff --git a/t/72pg.t b/t/72pg.t index 5f00ff9..24d6ae2 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -11,19 +11,20 @@ use DBICTest; use SQL::Abstract 'is_literal_value'; use DBIx::Class::_Util 'is_exception'; -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/}; -plan skip_all => <<'EOM' unless $dsn && $user; -Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test -( NOTE: This test drops and creates tables called 'artist', 'cd', -'timestamp_primary_key_test', 'track', 'casecheck', 'array_test' and -'sequence_test' as well as following sequences: 'pkid1_seq', 'pkid2_seq' and -'nonpkid_seq'. as well as following schemas: 'dbic_t_schema', -'dbic_t_schema_2', 'dbic_t_schema_3', 'dbic_t_schema_4', and 'dbic_t_schema_5') -EOM +plan skip_all => + 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test ' +. "( NOTE: This test drops and creates tables called 'artist', 'cd', " +. "'timestamp_primary_key_test', 'track', 'casecheck', 'array_test' and " +. "'sequence_test', the following sequences: 'pkid1_seq', 'pkid2_seq' " +. "and 'nonpkid_seq' and the following schemas: 'dbic_t_schema', " +. "'dbic_t_schema_2', 'dbic_t_schema_3', 'dbic_t_schema_4', and " +. "'dbic_t_schema_5')" +unless $dsn && $user; + +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'); ### load any test classes that are defined further down in the file via BEGIN blocks diff --git a/t/72pg_bytea.t b/t/72pg_bytea.t index ac5b9c4..56b2fcc 100644 --- a/t/72pg_bytea.t +++ b/t/72pg_bytea.t @@ -7,15 +7,15 @@ use Try::Tiny; 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' unless ($dsn && $dbuser); -my $schema = DBICTest::Schema->connect($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); +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 $schema = DBICTest::Schema->connect( $dsn, $dbuser, $dbpass ); if ($schema->storage->_server_info->{normalized_dbms_version} >= 9.0) { if (not try { DBD::Pg->VERSION('2.17.2') }) { diff --git a/t/73oracle_hq.t b/t/73oracle_hq.t index 6d27a05..4a80ffa 100644 --- a/t/73oracle_hq.t +++ b/t/73oracle_hq.t @@ -19,7 +19,7 @@ $ENV{NLS_LANG} = "AMERICAN"; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test.' - unless ($dsn && $user && $pass); + unless ($dsn && $user); plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_oracle') unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_oracle'); diff --git a/t/745db2.t b/t/745db2.t index 9123330..75f6814 100644 --- a/t/745db2.t +++ b/t/745db2.t @@ -8,16 +8,14 @@ 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"; - plan skip_all => 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); +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 $schema = DBICTest::Schema->connect($dsn, $user, $pass); my $name_sep = $schema->storage->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR'); diff --git a/t/746db2_400.t b/t/746db2_400.t index 3a5d902..e52f227 100644 --- a/t/746db2_400.t +++ b/t/746db2_400.t @@ -6,19 +6,17 @@ 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"; - # Probably best to pass the DBQ option in the DSN to specify a specific # libray. Something like: # DBICTEST_DB2_400_DSN='dbi:ODBC:dsn=MyAS400;DBQ=MYLIB' plan skip_all => 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); +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'); + plan tests => 6; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); diff --git a/t/746mssql.t b/t/746mssql.t index e4a9de0..867d920 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -5,10 +5,6 @@ use Test::More; use Test::Exception; use Try::Tiny; -use DBIx::Class::Optional::Dependencies (); -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'); - use lib qw(t/lib); use DBICTest; @@ -17,6 +13,10 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PA plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); +use DBIx::Class::Optional::Dependencies (); +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 $srv_ver = DBICTest::Schema->connect($dsn, $user, $pass)->storage->_server_info->{dbms_version}; ok ($srv_ver, 'Got a test server version on fresh schema: ' . ($srv_ver||'???') ); diff --git a/t/746sybase.t b/t/746sybase.t index af1f7a3..260bce4 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -209,7 +209,7 @@ SQL # test _insert_bulk using populate. SKIP: { - skip '_insert_bulk not supported', 4 + skip '_insert_bulk not supported', 1 unless $storage_type !~ /NoBindVars/i; lives_ok { @@ -245,7 +245,7 @@ SQL # make sure _insert_bulk works a second time on the same connection SKIP: { - skip '_insert_bulk not supported', 3 + skip '_insert_bulk not supported', 1 unless $storage_type !~ /NoBindVars/i; lives_ok { @@ -292,7 +292,7 @@ SQL # now test _insert_bulk with IDENTITY_INSERT SKIP: { - skip '_insert_bulk not supported', 3 + skip '_insert_bulk not supported', 1 unless $storage_type !~ /NoBindVars/i; lives_ok { @@ -333,9 +333,8 @@ SQL }); is $subq_rs->count, 11, 'correlated subquery'; -# mostly stolen from the blob stuff Nniuq wrote for t/73oracle.t SKIP: { - skip 'TEXT/IMAGE support does not work with FreeTDS', 22 + skip 'TEXT/IMAGE support does not work with FreeTDS', 1 if $schema->storage->_using_freetds; my $dbh = $schema->storage->_dbh; @@ -458,7 +457,7 @@ SQL # now try _insert_bulk with blobs and a non-blob which also happens to be an # identity column SKIP: { - skip 'no _insert_bulk without placeholders', 4 + skip 'no _insert_bulk without placeholders', 1 if $storage_type =~ /NoBindVars/i; $rs->delete; diff --git a/t/747mssql_ado.t b/t/747mssql_ado.t index 3fd7af6..3a7919a 100644 --- a/t/747mssql_ado.t +++ b/t/747mssql_ado.t @@ -8,17 +8,16 @@ 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; - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ADO_DSN}, _USER and _PASS to run this test' unless ($dsn && $user); +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'); + DBICTest::Schema->load_classes(qw/VaryingMAX ArtistGUID/); my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) ); diff --git a/t/748informix.t b/t/748informix.t index 42bdac8..9cd6111 100644 --- a/t/748informix.t +++ b/t/748informix.t @@ -7,16 +7,14 @@ 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"; - plan skip_all => 'Set $ENV{DBICTEST_INFORMIX_DSN}, _USER and _PASS to run this test' unless $dsn; +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 $schema = DBICTest::Schema->connect($dsn, $user, $pass, { auto_savepoint => 1 }); diff --git a/t/749sqlanywhere.t b/t/749sqlanywhere.t index 396e103..f445a66 100644 --- a/t/749sqlanywhere.t +++ b/t/749sqlanywhere.t @@ -9,40 +9,35 @@ 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); +my $env2optdep = { + DBICTEST_SQLANYWHERE => 'test_rdbms_sqlanywhere', + DBICTEST_SQLANYWHERE_ODBC => 'test_rdbms_sqlanywhere_odbc', +}; -DBICTest::Schema->load_classes('ArtistGUID'); +plan skip_all => join (' ', + 'Set $ENV{DBICTEST_SQLANYWHERE_DSN} and/or $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN},', + '_USER and _PASS to run these tests.', -# tests stolen from 748informix.t + 'WARNING: this test creates and drops the tables "artist", "bindtype_test" and', + '"sequence_test"; the generators "gen_artist_artistid", "pkid1_seq", "pkid2_seq"', + 'and "nonpkid_seq" and the trigger "artist_bi".', +) unless grep { $ENV{"${_}_DSN"} } keys %$env2optdep; -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 -EOF +my $schema; + +DBICTest::Schema->load_classes('ArtistGUID'); -my @info = ( - [ $dsn, $user, $pass ], - [ $dsn2, $user2, $pass2 ], -); +for my $prefix (keys %$env2optdep) { SKIP: { -my $schema; + my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/; -foreach my $info (@info) { - my ($dsn, $user, $pass) = @$info; + note "Testing with ${prefix}_DSN"; - next unless $dsn; + skip ("Skipping ${prefix}_DSN tests - envvar not set", 1 ) + unless $dsn; + + skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1) + unless DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix}); $schema = DBICTest::Schema->connect($dsn, $user, $pass, { auto_savepoint => 1 @@ -142,7 +137,7 @@ EOF 'empty insert works'; } -# test blobs (stolen from 73oracle.t) +# test blobs eval { $dbh->do('DROP TABLE bindtype_test') }; $dbh->do(qq[ CREATE TABLE bindtype_test @@ -254,7 +249,7 @@ SQL is try { $row_from_db->a_guid }, $row->a_guid, 'NON-PK GUID round trip (via ->search->all)'; } -} +}} done_testing; diff --git a/t/750firebird.t b/t/750firebird.t index d092379..2c836ba 100644 --- a/t/750firebird.t +++ b/t/750firebird.t @@ -9,6 +9,13 @@ use Try::Tiny; use lib qw(t/lib); use DBICTest; +# Example DSNs: +# 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 + my $env2optdep = { DBICTEST_FIREBIRD => 'test_rdbms_firebird', DBICTEST_FIREBIRD_INTERBASE => 'test_rdbms_firebird_interbase', @@ -25,25 +32,17 @@ plan skip_all => join (' ', 'and "nonpkid_seq" and the trigger "artist_bi".', ) unless grep { $ENV{"${_}_DSN"} } keys %$env2optdep; -# tests stolen from 749sybase_asa.t - -# Example DSNs: -# 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 - my $schema; for my $prefix (keys %$env2optdep) { SKIP: { my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/; - next unless $dsn; - note "Testing with ${prefix}_DSN"; + skip ("Skipping ${prefix}_DSN tests - envvar not set", 1 ) + unless $dsn; + skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1) unless DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix}); @@ -263,7 +262,7 @@ EOF if $schema->storage->dbh->{CachedKids}{$_}->FETCH('Active'); } -# test blobs (stolen from 73oracle.t) +# test blobs eval { $dbh->do('DROP TABLE "bindtype_test"') }; $dbh->do(q[ CREATE TABLE "bindtype_test" diff --git a/t/751msaccess.t b/t/751msaccess.t index bf4cdac..a12f6d2 100644 --- a/t/751msaccess.t +++ b/t/751msaccess.t @@ -13,15 +13,16 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSACCESS_ODBC_${_}" } qw/DSN U my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Test needs ' . - (join ' or ', map { $_ ? $_ : () } + (join ' and/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 + unless ( + (not $dsn || $dsn2) + or $dsn && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_odbc') - or + or $dsn2 && DBIx::Class::Optional::Dependencies->req_ok_for('test_rdbms_msaccess_ado') - or - (not $dsn || $dsn2); + ); DBICTest::Schema->load_classes('ArtistGUID'); @@ -274,10 +275,9 @@ EOF is $row->artistid, $current_artistid+2, 'autoincrement column functional aftear empty insert'; -# test blobs (stolen from 73oracle.t) - -# turn off horrendous binary DBIC_TRACE output +# test blobs { + # turn off horrendous binary DBIC_TRACE output local $schema->storage->{debug} = 0; eval { local $^W = 0; $dbh->do('DROP TABLE bindtype_test') }; diff --git a/t/inflate/datetime_firebird.t b/t/inflate/datetime_firebird.t index c958d6b..6713fb3 100644 --- a/t/inflate/datetime_firebird.t +++ b/t/inflate/datetime_firebird.t @@ -30,10 +30,11 @@ for my $prefix (keys %$env2optdep) { SKIP: { my ($dsn, $user, $pass) = map { $ENV{"${prefix}_$_"} } qw/DSN USER PASS/; - next unless $dsn; - note "Testing with ${prefix}_DSN"; + skip ("Skipping ${prefix}_DSN tests - envvar not set", 1 ) + unless $dsn; + skip ("Testing with ${prefix}_DSN needs " . DBIx::Class::Optional::Dependencies->req_missing_for( $env2optdep->{$prefix} ), 1) unless DBIx::Class::Optional::Dependencies->req_ok_for($env2optdep->{$prefix}); diff --git a/t/inflate/datetime_informix.t b/t/inflate/datetime_informix.t index 8bbd524..d8f3b6c 100644 --- a/t/inflate/datetime_informix.t +++ b/t/inflate/datetime_informix.t @@ -7,20 +7,19 @@ 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) { - plan skip_all => <<'EOF'; -Set $ENV{DBICTEST_INFORMIX_DSN} _USER and _PASS to run this test'. -Warning: This test drops and creates a table called 'event'"; -EOF -} +if (not $dsn) { plan skip_all => join(' ', + 'Set $ENV{DBICTEST_INFORMIX_DSN} _USER and _PASS to run this test', + "Warning: This test drops and creates a table called 'event'", +)} + +plan skip_all => 'Test needs ' . join (' and ', map { $_ ? $_ : () } ( + DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt'), + 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 $schema; diff --git a/t/inflate/datetime_msaccess.t b/t/inflate/datetime_msaccess.t index f012199..b4203dd 100644 --- a/t/inflate/datetime_msaccess.t +++ b/t/inflate/datetime_msaccess.t @@ -12,7 +12,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSACCESS_ODBC_${_}" } qw/DSN U my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSACCESS_ADO_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Test needs ' . - (join ' and ', map { $_ ? $_ : () } + (join ' and one or both of ', map { $_ ? $_ : () } DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), (join ' or ', map { $_ ? $_ : () } DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_msaccess_odbc'), diff --git a/t/inflate/datetime_mssql.t b/t/inflate/datetime_mssql.t index edbac14..dcd28ab 100644 --- a/t/inflate/datetime_mssql.t +++ b/t/inflate/datetime_mssql.t @@ -14,7 +14,7 @@ my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER my ($dsn3, $user3, $pass3) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Test needs ' . - (join ' and ', map { $_ ? $_ : () } + (join ' and one or more of ', map { $_ ? $_ : () } DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), (join ' or ', map { $_ ? $_ : () } DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_mssql_odbc'), diff --git a/t/inflate/datetime_oracle.t b/t/inflate/datetime_oracle.t index 98e4b53..8cd888f 100644 --- a/t/inflate/datetime_oracle.t +++ b/t/inflate/datetime_oracle.t @@ -7,9 +7,6 @@ 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)) { @@ -17,6 +14,10 @@ if (not ($dsn && $user && $pass)) { 'Warning: This test drops and creates a table called \'event\''; } +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_sqlanywhere.t b/t/inflate/datetime_sqlanywhere.t index 676665f..38a6875 100644 --- a/t/inflate/datetime_sqlanywhere.t +++ b/t/inflate/datetime_sqlanywhere.t @@ -11,7 +11,7 @@ my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SQLANYWHERE_${_}" } qw/DS my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_SQLANYWHERE_ODBC_${_}" } qw/DSN USER PASS/}; plan skip_all => 'Test needs ' . - (join ' and ', map { $_ ? $_ : () } + (join ' and one or both of ', map { $_ ? $_ : () } DBIx::Class::Optional::Dependencies->req_missing_for('test_dt'), (join ' or ', map { $_ ? $_ : () } DBIx::Class::Optional::Dependencies->req_missing_for('test_rdbms_sqlanywhere'), diff --git a/t/inflate/datetime_sybase.t b/t/inflate/datetime_sybase.t index 597f6a3..27b93da 100644 --- a/t/inflate/datetime_sybase.t +++ b/t/inflate/datetime_sybase.t @@ -9,20 +9,20 @@ 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_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' and " . - "'event_small_dt'"; -} +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 a table called 'track' and ", + "'event_small_dt'", +) } + +plan skip_all => 'Test needs ' . join (' and ', map { $_ ? $_ : () } ( + DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt'), + 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'); DBICTest::Schema->load_classes('EventSmallDT');