From: Dagfinn Ilmari Mannsåker Date: Mon, 28 Jul 2014 17:40:36 +0000 (+0100) Subject: Use skip_all or diag for missing RDBMS test dependencies X-Git-Tag: 0.07041~31 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4fb2971cd5784d8bc64f98052e691db9df697516;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Use skip_all or diag for missing RDBMS test dependencies This way we get a list of all the missing modules if DBICTEST_FOO_DSN is set, but something is missing. --- diff --git a/t/10_02mysql_common.t b/t/10_02mysql_common.t index 26f086a..e850cbf 100644 --- a/t/10_02mysql_common.t +++ b/t/10_02mysql_common.t @@ -4,6 +4,7 @@ use Test::More; use Test::Exception; use Try::Tiny; use File::Path 'rmtree'; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader::Utils 'slurp_file'; use DBIx::Class::Schema::Loader 'make_schema_at'; @@ -504,6 +505,9 @@ EOF if( !$dsn || !$user ) { $tester->skip_tests('You need to set the DBICTEST_MYSQL_DSN, DBICTEST_MYSQL_USER, and DBICTEST_MYSQL_PASS environment variables'); } +elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_mysql')) { + $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_mysql')); +} else { diag $skip_rels_msg if not $test_innodb; $tester->run_tests(); diff --git a/t/10_03pg_common.t b/t/10_03pg_common.t index c1b75b3..0c66a3c 100644 --- a/t/10_03pg_common.t +++ b/t/10_03pg_common.t @@ -1,6 +1,7 @@ use strict; use warnings; use utf8; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use DBIx::Class::Schema::Loader::Utils qw/no_warnings slurp_file/; use Test::More; @@ -489,6 +490,9 @@ my $tester = dbixcsl_common_tests->new( if( !$dsn || !$user ) { $tester->skip_tests('You need to set the DBICTEST_PG_DSN, _USER, and _PASS environment variables'); } +elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg')) { + $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg')); +} else { $tester->run_tests(); } diff --git a/t/10_04db2_common.t b/t/10_04db2_common.t index e0804b8..4dd1936 100644 --- a/t/10_04db2_common.t +++ b/t/10_04db2_common.t @@ -4,6 +4,7 @@ use Test::More; use Test::Exception; use Try::Tiny; use File::Path 'rmtree'; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use lib qw(t/lib); @@ -20,6 +21,9 @@ my $password = $ENV{DBICTEST_DB2_PASS} || ''; plan skip_all => 'You need to set the DBICTEST_DB2_DSN, _USER, and _PASS environment variables' unless ($dsn && $user); +plan skip_all => 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_db2') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_db2'); + my ($schema, $schemas_created); # for cleanup in END for extra tests my $srv_ver = do { diff --git a/t/10_05ora_common.t b/t/10_05ora_common.t index 74e0e0d..2cb7480 100644 --- a/t/10_05ora_common.t +++ b/t/10_05ora_common.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use DBIx::Class::Schema::Loader::Utils qw/slurp_file split_name/; use Try::Tiny; @@ -475,6 +476,9 @@ EOF if( !$dsn || !$user ) { $tester->skip_tests('You need to set the DBICTEST_ORA_DSN, _USER, and _PASS environment variables'); } +elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_oracle')) { + $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_oracle')); +} else { $tester->run_tests(); } diff --git a/t/10_06sybase_common.t b/t/10_06sybase_common.t index 645fc6c..de2ec39 100644 --- a/t/10_06sybase_common.t +++ b/t/10_06sybase_common.t @@ -4,6 +4,7 @@ use Test::More; use Test::Exception; use Try::Tiny; use File::Path 'rmtree'; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/; use namespace::clean; @@ -394,6 +395,9 @@ EOF if( !$dsn || !$user ) { $tester->skip_tests('You need to set the DBICTEST_SYBASE_DSN, _USER, and _PASS environment variables'); } +elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_ase')) { + $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_ase')); +} else { $tester->run_tests(); } diff --git a/t/10_07mssql_common.t b/t/10_07mssql_common.t index 4a84e69..b7eeb80 100644 --- a/t/10_07mssql_common.t +++ b/t/10_07mssql_common.t @@ -2,6 +2,7 @@ use strict; use warnings; use Test::More; use Test::Exception; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader::Utils qw/warnings_exist_silent sigwarn_silencer/; use Try::Tiny; use File::Path 'rmtree'; @@ -31,6 +32,13 @@ my ($dsns, $common_version); for (qw/MSSQL MSSQL_ODBC MSSQL_ADO/) { next unless $ENV{"DBICTEST_${_}_DSN"}; + (my $dep_group = lc "rdbms_$_") =~ s/mssql$/mssql_sybase/; + if (!DBIx::Class::Optional::Dependencies->req_ok_for($dep_group)) { + diag 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for($dep_group) + . " to test with $_"; + next; + } + $dsns->{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"}; $dsns->{$_}{user} = $ENV{"DBICTEST_${_}_USER"}; $dsns->{$_}{password} = $ENV{"DBICTEST_${_}_PASS"}; diff --git a/t/10_08sqlanywhere_common.t b/t/10_08sqlanywhere_common.t index c3299b5..6fff6d0 100644 --- a/t/10_08sqlanywhere_common.t +++ b/t/10_08sqlanywhere_common.t @@ -4,6 +4,7 @@ use Test::More; use Test::Exception; use Try::Tiny; use File::Path 'rmtree'; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use Scope::Guard (); @@ -19,30 +20,31 @@ use constant EXTRA_DUMP_DIR => "$tdir/sqlanywhere_extra_dump"; # # Setting them to zero is preferred. -my $dbd_sqlanywhere_dsn = $ENV{DBICTEST_SQLANYWHERE_DSN} || ''; -my $dbd_sqlanywhere_user = $ENV{DBICTEST_SQLANYWHERE_USER} || ''; -my $dbd_sqlanywhere_password = $ENV{DBICTEST_SQLANYWHERE_PASS} || ''; +my %dsns; +for (qw(SQLANYWHERE SQLANYWHERE_ODBC)) { + next unless $ENV{"DBICTEST_${_}_DSN"}; -my $odbc_dsn = $ENV{DBICTEST_SQLANYWHERE_ODBC_DSN} || ''; -my $odbc_user = $ENV{DBICTEST_SQLANYWHERE_ODBC_USER} || ''; -my $odbc_password = $ENV{DBICTEST_SQLANYWHERE_ODBC_PASS} || ''; + my $dep_group = lc "rdbms_$_"; + if (!DBIx::Class::Optional::Dependencies->req_ok_for($dep_group)) { + diag 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for($dep_group) + . " to test with $_"; + next; + } + + $dsns{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"}; + $dsns{$_}{user} = $ENV{"DBICTEST_${_}_USER"}; + $dsns{$_}{password} = $ENV{"DBICTEST_${_}_PASS"}; +}; + +plan skip_all => 'You need to set the DBICTEST_SQLANYWHERE_DSN, _USER and _PASS and/or the DBICTEST_SQLANYWHERE_ODBC_DSN, _USER and _PASS environment variables' + unless %dsns; my ($schema, $schemas_created); # for cleanup in END for extra tests my $tester = dbixcsl_common_tests->new( vendor => 'SQLAnywhere', auto_inc_pk => 'INTEGER IDENTITY NOT NULL PRIMARY KEY', - connect_info => [ ($dbd_sqlanywhere_dsn ? { - dsn => $dbd_sqlanywhere_dsn, - user => $dbd_sqlanywhere_user, - password => $dbd_sqlanywhere_password, - } : ()), - ($odbc_dsn ? { - dsn => $odbc_dsn, - user => $odbc_user, - password => $odbc_password, - } : ()), - ], + connect_info => [ values %dsns ], loader_options => { preserve_case => 1 }, default_is_deferrable => 1, default_on_clause => 'RESTRICT', @@ -398,12 +400,7 @@ EOF }, ); -if (not ($dbd_sqlanywhere_dsn || $odbc_dsn)) { - $tester->skip_tests('You need to set the DBICTEST_SQLANYWHERE_DSN, _USER and _PASS and/or the DBICTEST_SQLANYWHERE_ODBC_DSN, _USER and _PASS environment variables'); -} -else { - $tester->run_tests(); -} +$tester->run_tests(); sub extra_cleanup { if (not $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) { diff --git a/t/10_09firebird_common.t b/t/10_09firebird_common.t index cedd461..65ce5c0 100644 --- a/t/10_09firebird_common.t +++ b/t/10_09firebird_common.t @@ -2,21 +2,31 @@ use strict; use warnings; use Test::More; use Scope::Guard (); +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader::Utils qw/sigwarn_silencer/; use lib qw(t/lib); use dbixcsl_common_tests; -my $dbd_firebird_dsn = $ENV{DBICTEST_FIREBIRD_DSN} || ''; -my $dbd_firebird_user = $ENV{DBICTEST_FIREBIRD_USER} || ''; -my $dbd_firebird_password = $ENV{DBICTEST_FIREBIRD_PASS} || ''; +my %dsns; +for (qw(FIREBIRD FIREBIRD_ODBC FIREBIRD_INTERBASE)) { + next unless $ENV{"DBICTEST_${_}_DSN"}; -my $dbd_interbase_dsn = $ENV{DBICTEST_FIREBIRD_INTERBASE_DSN} || ''; -my $dbd_interbase_user = $ENV{DBICTEST_FIREBIRD_INTERBASE_USER} || ''; -my $dbd_interbase_password = $ENV{DBICTEST_FIREBIRD_INTERBASE_PASS} || ''; + my $dep_group = lc "rdbms_$_"; + if (!DBIx::Class::Optional::Dependencies->req_ok_for($dep_group)) { + diag 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for($dep_group) + . " to test with $_"; + next; + } + + $dsns{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"}; + $dsns{$_}{user} = $ENV{"DBICTEST_${_}_USER"}; + $dsns{$_}{password} = $ENV{"DBICTEST_${_}_PASS"}; + $dsns{$_}{connect_info_opts} = { on_connect_call => 'use_softcommit' } + if /\AFIREBIRD(?:_INTERBASE)\z/; +}; -my $odbc_dsn = $ENV{DBICTEST_FIREBIRD_ODBC_DSN} || ''; -my $odbc_user = $ENV{DBICTEST_FIREBIRD_ODBC_USER} || ''; -my $odbc_password = $ENV{DBICTEST_FIREBIRD_ODBC_PASS} || ''; +plan skip_all => 'You need to set the DBICTEST_FIREBIRD_DSN, _USER and _PASS and/or the DBICTEST_FIREBIRD_ODBC_DSN, _USER and _PASS and/or the DBICTEST_FIREBIRD_INTERBASE_DSN, _USER and _PASS environment variables' + unless %dsns; my $schema; @@ -48,25 +58,7 @@ my $tester = dbixcsl_common_tests->new( null => '', preserve_case_mode_is_exclusive => 1, quote_char => '"', - connect_info => [ - ($dbd_firebird_dsn ? { - dsn => $dbd_firebird_dsn, - user => $dbd_firebird_user, - password => $dbd_firebird_password, - connect_info_opts => { on_connect_call => 'use_softcommit' }, - } : ()), - ($dbd_interbase_dsn ? { - dsn => $dbd_interbase_dsn, - user => $dbd_interbase_user, - password => $dbd_interbase_password, - connect_info_opts => { on_connect_call => 'use_softcommit' }, - } : ()), - ($odbc_dsn ? { - dsn => $odbc_dsn, - user => $odbc_user, - password => $odbc_password, - } : ()), - ], + connect_info => [ values %dsns ], data_types => { # based on the Interbase Data Definition Guide # http://www.ibphoenix.com/downloads/60DataDef.zip @@ -202,12 +194,9 @@ q{ }, ); -if (not ($dbd_firebird_dsn || $dbd_interbase_dsn || $odbc_dsn)) { - $tester->skip_tests('You need to set the DBICTEST_FIREBIRD_DSN, _USER and _PASS and/or the DBICTEST_FIREBIRD_INTERBASE_DSN and/or the DBICTEST_FIREBIRD_ODBC_DSN environment variables'); -} -else { +{ # get rid of stupid warning from InterBase/GetInfo.pm - if ($dbd_interbase_dsn) { + if ($dsns{FIREBIRD_INTERBASE}) { local $SIG{__WARN__} = sigwarn_silencer( qr{^Use of uninitialized value in sprintf at \S+DBD/InterBase/GetInfo\.pm line \d+\.$|^Missing argument in sprintf at \S+DBD/InterBase/GetInfo.pm line \d+\.$} ); diff --git a/t/10_10informix_common.t b/t/10_10informix_common.t index aada1ea..e8b6b58 100644 --- a/t/10_10informix_common.t +++ b/t/10_10informix_common.t @@ -4,6 +4,7 @@ use Test::More; use Test::Exception; use Try::Tiny; use File::Path 'rmtree'; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader 'make_schema_at'; use DBIx::Class::Schema::Loader::Utils 'split_name'; use String::ToIdentifier::EN::Unicode 'to_identifier'; @@ -335,6 +336,9 @@ EOF if( !$dsn ) { $tester->skip_tests('You need to set the DBICTEST_INFORMIX_DSN, _USER, and _PASS environment variables'); } +elsif (!DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_informix')) { + $tester->skip_tests('You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_informix')); +} else { $tester->run_tests(); } diff --git a/t/10_11msaccess_common.t b/t/10_11msaccess_common.t index a9e0c86..c71024b 100644 --- a/t/10_11msaccess_common.t +++ b/t/10_11msaccess_common.t @@ -1,17 +1,29 @@ use strict; use warnings; use Test::More; +use DBIx::Class::Optional::Dependencies; use DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS (); use lib qw(t/lib); use dbixcsl_common_tests; -my $odbc_dsn = $ENV{DBICTEST_MSACCESS_ODBC_DSN} || ''; -my $odbc_user = $ENV{DBICTEST_MSACCESS_ODBC_USER} || ''; -my $odbc_password = $ENV{DBICTEST_MSACCESS_ODBC_PASS} || ''; +my %dsns; +for (qw(MSACCESS_ODBC MSACCESS_ADO)) { + next unless $ENV{"DBICTEST_${_}_DSN"}; -my $ado_dsn = $ENV{DBICTEST_MSACCESS_ADO_DSN} || ''; -my $ado_user = $ENV{DBICTEST_MSACCESS_ADO_USER} || ''; -my $ado_password = $ENV{DBICTEST_MSACCESS_ADO_PASS} || ''; + my $dep_group = lc "rdbms_$_"; + if (!DBIx::Class::Optional::Dependencies->req_ok_for($dep_group)) { + diag 'You need to install ' . DBIx::Class::Optional::Dependencies->req_missing_for($dep_group) + . " to test with $_"; + next; + } + + $dsns{$_}{dsn} = $ENV{"DBICTEST_${_}_DSN"}; + $dsns{$_}{user} = $ENV{"DBICTEST_${_}_USER"}; + $dsns{$_}{password} = $ENV{"DBICTEST_${_}_PASS"}; +}; + +plan skip_all => 'You need to set the DBICTEST_MSACCESS_ODBC_DSN, _USER and _PASS and/or the DBICTEST_MSACCESS_ADO_DSN, _USER and _PASS environment variables' + unless %dsns; my %ado_extra_types = ( 'tinyint' => { data_type => 'tinyint', original => { data_type => 'byte' } }, @@ -38,17 +50,7 @@ my $tester = dbixcsl_common_tests->new( vendor => 'Access', auto_inc_pk => 'AUTOINCREMENT PRIMARY KEY', quote_char => [qw/[ ]/], - connect_info => [ ($odbc_dsn ? { - dsn => $odbc_dsn, - user => $odbc_user, - password => $odbc_password, - } : ()), - ($ado_dsn ? { - dsn => $ado_dsn, - user => $ado_user, - password => $ado_password, - } : ()), - ], + connect_info => [ values %dsns ], data_types => { # http://msdn.microsoft.com/en-us/library/bb208866(v=office.12).aspx # @@ -114,8 +116,7 @@ my $tester = dbixcsl_common_tests->new( package DBIXCSL_Test::DummySchema; use base 'DBIx::Class::Schema'; } - my @connect_info = $odbc_dsn ? ($odbc_dsn, $odbc_user, $odbc_password) - : ($ado_dsn, $ado_user, $ado_password); + my @connect_info = @{$dsns{MSACCESS_ODBC} || $dsns{MSACCESS_ADO}}; my $schema = DBIXCSL_Test::DummySchema->connect(@connect_info); @@ -135,11 +136,6 @@ my $tester = dbixcsl_common_tests->new( }, ); -if (not ($odbc_dsn || $ado_dsn)) { - $tester->skip_tests('You need to set the DBICTEST_MSACCESS_ODBC_DSN, and optionally _USER and _PASS and/or the DBICTEST_MSACCESS_ADO_DSN, and optionally _USER and _PASS environment variables'); -} -else { - $tester->run_tests(); -} +$tester->run_tests(); # vim:et sts=4 sw=4 tw=0: