From: Peter Rabbitson Date: Mon, 30 Aug 2010 04:38:34 +0000 (+0200) Subject: Massive cleanup of DateTime test dependencies, other interim X-Git-Tag: v0.08124~93 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68de943862f06cabd397d2e74d12cd9cdc999779;p=dbsrgits%2FDBIx-Class.git Massive cleanup of DateTime test dependencies, other interim janitorial work --- diff --git a/Changes b/Changes index c1f7906..d23d8b9 100644 --- a/Changes +++ b/Changes @@ -37,6 +37,7 @@ Revision history for DBIx::Class from tests (RT#59565) - Do not execute t/zzzzzzz_sqlite_deadlock.t for regular module installs - test is prone to spontaneous blow up + - DT-related tests now require a DateTime >= 0.55 (RT#60324) 0.08123 2010-06-12 14:46 (UTC) * Fixes diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 6d4ed6f..65994bf 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -12,16 +12,26 @@ use Carp; # Makefile.PL in $AUTHOR mode my $moose_basic = { - 'Moose' => '0.98', - 'MooseX::Types' => '0.21', + 'Moose' => '0.98', + 'MooseX::Types' => '0.21', +}; + +my $replicated = { + %$moose_basic, + 'Hash::Merge' => '0.12', }; my $admin_basic = { %$moose_basic, - 'MooseX::Types::Path::Class' => '0.05', - 'MooseX::Types::JSON' => '0.02', - 'JSON::Any' => '1.22', - 'namespace::autoclean' => '0.09', + 'MooseX::Types::Path::Class' => '0.05', + 'MooseX::Types::JSON' => '0.02', + 'JSON::Any' => '1.22', + 'namespace::autoclean' => '0.09', +}; + +my $datetime_basic = { + 'DateTime' => '0.55', + 'DateTime::Format::Strptime' => '1.2', }; my $reqs = { @@ -30,16 +40,21 @@ my $reqs = { }, replicated => { - req => { - %$moose_basic, - 'Hash::Merge' => '0.12', - }, + req => $replicated, pod => { title => 'Storage::Replicated', desc => 'Modules required for L', }, }, + test_replicated => { + req => { + %$replicated, + 'Test::Moose' => '0', + }, + }, + + admin => { req => { %$admin_basic, @@ -106,26 +121,38 @@ my $reqs = { }, }, - test_dtrelated => { + test_dt => { + req => $datetime_basic, + }, + + test_dt_sqlite => { req => { + %$datetime_basic, # t/36datetime.t # t/60core.t 'DateTime::Format::SQLite' => '0', + }, + }, - # t/96_is_deteministic_value.t - 'DateTime::Format::Strptime'=> '0', - + test_dt_mysql => { + req => { + %$datetime_basic, # t/inflate/datetime_mysql.t # (doesn't need Mysql itself) - 'DateTime::Format::MySQL' => '0', + 'DateTime::Format::MySQL' => '0', + }, + }, + test_dt_pg => { + req => { + %$datetime_basic, # t/inflate/datetime_pg.t # (doesn't need PG itself) - 'DateTime::Format::Pg' => '0', + 'DateTime::Format::Pg' => '0', }, }, - cdbicompat => { + test_cdbicompat => { req => { 'DBIx::ContextualFetch' => '0', 'Class::DBI::Plugin::DeepAbstractSearch' => '0', @@ -136,7 +163,7 @@ my $reqs = { }, }, - rdbms_pg => { + test_rdbms_pg => { req => { $ENV{DBICTEST_PG_DSN} ? ( @@ -146,7 +173,7 @@ my $reqs = { }, }, - rdbms_mysql => { + test_rdbms_mysql => { req => { $ENV{DBICTEST_MYSQL_DSN} ? ( @@ -155,7 +182,7 @@ my $reqs = { }, }, - rdbms_oracle => { + test_rdbms_oracle => { req => { $ENV{DBICTEST_ORA_DSN} ? ( @@ -165,7 +192,7 @@ my $reqs = { }, }, - rdbms_ase => { + test_rdbms_ase => { req => { $ENV{DBICTEST_SYBASE_DSN} ? ( @@ -174,16 +201,7 @@ my $reqs = { }, }, - rdbms_asa => { - req => { - (scalar grep { $ENV{$_} } (qw/DBICTEST_SYBASE_ASA_DSN DBICTEST_SYBASE_ASA_ODBC_DSN/) ) - ? ( - 'DateTime::Format::Strptime' => 0, - ) : () - }, - }, - - rdbms_db2 => { + test_rdbms_db2 => { req => { $ENV{DBICTEST_DB2_DSN} ? ( diff --git a/t/105view_deps.t b/t/105view_deps.t index a2e5485..d056e9d 100644 --- a/t/105view_deps.t +++ b/t/105view_deps.t @@ -12,12 +12,13 @@ use ViewDepsBad; BEGIN { require DBIx::Class; - plan skip_all => 'Test needs ' - . DBIx::Class::Optional::Dependencies->req_missing_for('deploy') - unless DBIx::Class::Optional::Dependencies->req_ok_for('deploy'); - use_ok('DBIx::Class::ResultSource::View'); + plan skip_all => 'Test needs ' . + DBIx::Class::Optional::Dependencies->req_missing_for('deploy') + unless DBIx::Class::Optional::Dependencies->req_ok_for('deploy'); } +use_ok('DBIx::Class::ResultSource::View'); + #################### SANITY my $view = DBIx::Class::ResultSource::View->new; diff --git a/t/40resultsetmanager.t b/t/40resultsetmanager.t index 66f9598..2ac44eb 100644 --- a/t/40resultsetmanager.t +++ b/t/40resultsetmanager.t @@ -5,20 +5,11 @@ use Test::More; use lib qw(t/lib); BEGIN { - eval { require Class::Inspector }; - if ($@ =~ m{Can.t locate Class/Inspector.pm}) { - plan skip_all => "ResultSetManager requires Class::Inspector"; - } else { - plan tests => 4; - } -} - -BEGIN { local $SIG{__WARN__} = sub {}; require DBIx::Class::ResultSetManager; } -use DBICTest::ResultSetManager; # uses Class::Inspector +use DBICTest::ResultSetManager; my $schema = DBICTest::ResultSetManager->compose_namespace('DB'); my $rs = $schema->resultset('Foo'); @@ -27,3 +18,5 @@ ok( !DB::Foo->can('bar'), 'Foo class does not have bar method' ); ok( $rs->can('bar'), 'Foo resultset class has bar method' ); isa_ok( $rs, 'DBICTest::ResultSetManager::Foo::_resultset', 'Foo resultset class is correct' ); is( $rs->bar, 'good', 'bar method works' ); + +done_testing; diff --git a/t/71mysql.t b/t/71mysql.t index f935afd..01c32d8 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use Test::Exception; diff --git a/t/72pg.t b/t/72pg.t index cdfce99..67911aa 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -32,8 +32,10 @@ DBICTest::Schema->load_classes( map {s/.+:://;$_} @test_classes ) if @test_class # Check that datetime_parser returns correctly before we explicitly connect. SKIP: { - eval { require DateTime::Format::Pg }; - skip "DateTime::Format::Pg required", 2 if $@; + skip ( + "Pg parser detection test needs " . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg'), + 2 + ) unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg'); my $store = ref $s->storage; is($store, 'DBIx::Class::Storage::DBI', 'Started with generic storage'); diff --git a/t/746db2_400.t b/t/746db2_400.t index 359c13e..29b7ff1 100644 --- a/t/746db2_400.t +++ b/t/746db2_400.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); diff --git a/t/746sybase.t b/t/746sybase.t index 2210db7..6b54699 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; no warnings 'uninitialized'; use Test::More; diff --git a/t/77join_count.t b/t/77join_count.t index f46ad04..8350e2e 100644 --- a/t/77join_count.t +++ b/t/77join_count.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); @@ -7,10 +7,6 @@ use DBICTest; my $schema = DBICTest->init_schema(); -eval "use DBD::SQLite"; -plan skip_all => 'needs DBD::SQLite for testing' if $@; -plan tests => 4; - cmp_ok($schema->resultset("CD")->count({ 'artist.name' => 'Caterwauler McCrae' }, { join => 'artist' }), '==', 3, 'Count by has_a ok'); @@ -29,3 +25,4 @@ cmp_ok($schema->resultset("CD")->count( { join => [ qw/tags liner_notes/ ] } ), '==', 2, "Mixed count ok"); +done_testing; diff --git a/t/93nobindvars.t b/t/93nobindvars.t index e6ee0eb..a2e0cba 100644 --- a/t/93nobindvars.t +++ b/t/93nobindvars.t @@ -1,9 +1,5 @@ use strict; -use warnings; - -# Copied from 71mysql.t, manually using NoBindVars. This is to give that code -# wider testing, since virtually nobody who regularly runs the test suite -# is using DBD::Sybase+FreeTDS+MSSQL -- blblack +use warnings; use Test::More; use lib qw(t/lib); @@ -17,8 +13,6 @@ 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 tests => 4; - { # Fake storage driver for mysql + no bind variables package DBIx::Class::Storage::DBI::MySQLNoBindVars; use Class::C3; @@ -68,3 +62,5 @@ END { my $dbh = eval { $schema->storage->_dbh }; $dbh->do("DROP TABLE artist") if $dbh; } + +done_testing; diff --git a/t/94versioning.t b/t/94versioning.t index 2e0d18e..a21141a 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -1,13 +1,10 @@ use strict; use warnings; + use Test::More; use Test::Warn; use Test::Exception; -use Path::Class; -use File::Copy; - -#warn "$dsn $user $pass"; my ($dsn, $user, $pass); BEGIN { @@ -16,16 +13,16 @@ BEGIN { plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($dsn); - eval { require Time::HiRes } - || plan skip_all => 'Test needs Time::HiRes'; - Time::HiRes->import(qw/time sleep/); - require DBIx::Class; plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('deploy') unless DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') } +use Path::Class; +use File::Copy; +use Time::HiRes qw/time sleep/; + use lib qw(t/lib); use DBICTest; # do not remove even though it is not used diff --git a/t/96_is_deteministic_value.t b/t/96_is_deteministic_value.t index b6ca886..840a1c5 100644 --- a/t/96_is_deteministic_value.t +++ b/t/96_is_deteministic_value.t @@ -1,15 +1,17 @@ use strict; use warnings; -# 6 tests - use Test::More; +use Test::Exception; + +BEGIN { + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); +} + use lib qw(t/lib); use DBICTest; -plan skip_all => "DateTime required" unless eval { require DateTime }; -eval "use DateTime::Format::Strptime"; -plan skip_all => 'DateTime::Format::Strptime required' if $@; -use Test::Exception; my $schema = DBICTest->init_schema(); my $artist_rs = $schema->resultset('Artist'); diff --git a/t/98savepoints.t b/t/98savepoints.t index 4ca9a95..45fe577 100644 --- a/t/98savepoints.t +++ b/t/98savepoints.t @@ -2,9 +2,6 @@ use strict; use warnings; use Test::More; -use lib qw(t/lib); -use DBICTest; -use DBICTest::Stats; my ($create_sql, $dsn, $user, $pass); @@ -20,6 +17,10 @@ if ($ENV{DBICTEST_PG_DSN}) { plan skip_all => 'Set DBICTEST_(PG|MYSQL)_DSN _USER and _PASS if you want to run savepoint tests'; } +use lib qw(t/lib); +use DBICTest; +use DBICTest::Stats; + plan tests => 16; my $schema = DBICTest::Schema->connect ($dsn,$user,$pass,{ auto_savepoint => 1 }); diff --git a/t/99dbic_sqlt_parser.t b/t/99dbic_sqlt_parser.t index 5ba72a8..61202b7 100644 --- a/t/99dbic_sqlt_parser.t +++ b/t/99dbic_sqlt_parser.t @@ -3,9 +3,6 @@ use warnings; use Test::More; use Test::Exception; -use lib qw(t/lib); -use DBICTest; -use DBICTest::Schema; use Scalar::Util (); BEGIN { @@ -15,6 +12,10 @@ BEGIN { unless DBIx::Class::Optional::Dependencies->req_ok_for ('deploy') } +use lib qw(t/lib); +use DBICTest; +use DBICTest::Schema; + # Test for SQLT-related leaks { my $s = DBICTest::Schema->clone; diff --git a/t/admin/03data.t b/t/admin/03data.t index 884b120..872b1cf 100644 --- a/t/admin/03data.t +++ b/t/admin/03data.t @@ -2,7 +2,6 @@ use strict; use warnings; use Test::More; - use Test::Exception; BEGIN { diff --git a/t/bind/bindtype_columns.t b/t/bind/bindtype_columns.t index 72b460c..90ad8c6 100644 --- a/t/bind/bindtype_columns.t +++ b/t/bind/bindtype_columns.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); diff --git a/t/cdbi/02-Film.t b/t/cdbi/02-Film.t index f1477cc..2eb4f05 100644 --- a/t/cdbi/02-Film.t +++ b/t/cdbi/02-Film.t @@ -8,7 +8,6 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } plan tests => 98; } diff --git a/t/cdbi/03-subclassing.t b/t/cdbi/03-subclassing.t index 8527fea..433999d 100644 --- a/t/cdbi/03-subclassing.t +++ b/t/cdbi/03-subclassing.t @@ -11,8 +11,7 @@ BEGIN { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6); + plan tests => 6; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/06-hasa.t b/t/cdbi/06-hasa.t index 0fb3946..8cc8301 100644 --- a/t/cdbi/06-hasa.t +++ b/t/cdbi/06-hasa.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 24); + plan tests => 24; } @YA::Film::ISA = 'Film'; diff --git a/t/cdbi/09-has_many.t b/t/cdbi/09-has_many.t index 96b50c0..b9048dc 100644 --- a/t/cdbi/09-has_many.t +++ b/t/cdbi/09-has_many.t @@ -5,8 +5,7 @@ use Test::More; BEGIN { eval "use DBIx::Class::CDBICompat;"; plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@; - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 31); + plan tests => 31; } diff --git a/t/cdbi/11-triggers.t b/t/cdbi/11-triggers.t index 918403a..37c179c 100644 --- a/t/cdbi/11-triggers.t +++ b/t/cdbi/11-triggers.t @@ -7,8 +7,7 @@ BEGIN { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 13); + plan tests => 13; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/12-filter.t b/t/cdbi/12-filter.t index bdc9687..109c876 100644 --- a/t/cdbi/12-filter.t +++ b/t/cdbi/12-filter.t @@ -7,8 +7,7 @@ BEGIN { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 50); + plan tests => 50; } use lib 't/cdbi/testlib'; @@ -129,10 +128,6 @@ test_normal_iterator; # make sure nothing gets clobbered; test_normal_iterator; -SKIP: { - #skip "dbic iterators don't support slice yet", 12; - - { my @acts = $film->actors->slice(1, 2); is @acts, 2, "Slice gives 2 actor"; @@ -177,5 +172,3 @@ delete $film->{related_resultsets}; eval { $film->actors->delete_all }; is $@, '', "Deleting again does no harm"; } - -} # end SKIP block diff --git a/t/cdbi/13-constraint.t b/t/cdbi/13-constraint.t index b5b8f32..51b283a 100644 --- a/t/cdbi/13-constraint.t +++ b/t/cdbi/13-constraint.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 23); + plan tests => 23; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/14-might_have.t b/t/cdbi/14-might_have.t index a8c163f..156a089 100644 --- a/t/cdbi/14-might_have.t +++ b/t/cdbi/14-might_have.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 22); + plan tests => 22; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/15-accessor.t b/t/cdbi/15-accessor.t index b0b684c..39330e3 100644 --- a/t/cdbi/15-accessor.t +++ b/t/cdbi/15-accessor.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 75); + plan tests => 75; } INIT { diff --git a/t/cdbi/16-reserved.t b/t/cdbi/16-reserved.t index 67693a0..201042b 100644 --- a/t/cdbi/16-reserved.t +++ b/t/cdbi/16-reserved.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 5); + plan tests => 5; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/18-has_a.t b/t/cdbi/18-has_a.t index 9732b65..a87c9f6 100644 --- a/t/cdbi/18-has_a.t +++ b/t/cdbi/18-has_a.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 41); + plan tests => 41; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/19-set_sql.t b/t/cdbi/19-set_sql.t index ebd571d..7118e4a 100644 --- a/t/cdbi/19-set_sql.t +++ b/t/cdbi/19-set_sql.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 20); + plan tests => 20; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/21-iterator.t b/t/cdbi/21-iterator.t index 6be3a5c..c6f6c3a 100644 --- a/t/cdbi/21-iterator.t +++ b/t/cdbi/21-iterator.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 37); + plan tests => 37; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/22-deflate_order.t b/t/cdbi/22-deflate_order.t index 3d53245..1de3f87 100644 --- a/t/cdbi/22-deflate_order.t +++ b/t/cdbi/22-deflate_order.t @@ -3,18 +3,14 @@ use strict; use Test::More; -eval "use DBIx::Class::CDBICompat;"; +eval "use DBIx::Class::CDBICompat; use Time::Piece::MySQL;"; if ($@) { - plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - next; + plan (skip_all => "Time::Piece::MySQL, Class::Trigger and DBIx::ContextualFetch required: $@"); } plan skip_all => 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test' unless ($ENV{DBICTEST_MYSQL_DSN} && $ENV{DBICTEST_MYSQL_USER}); -eval { require Time::Piece::MySQL }; -plan skip_all => "Need Time::Piece::MySQL for this test" if $@; - plan tests => 3; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/23-cascade.t b/t/cdbi/23-cascade.t index a681882..dbd55c6 100644 --- a/t/cdbi/23-cascade.t +++ b/t/cdbi/23-cascade.t @@ -6,10 +6,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 12); + plan tests => 12; } INIT { diff --git a/t/cdbi/24-meta_info.t b/t/cdbi/24-meta_info.t index 7a269bd..ba72f17 100644 --- a/t/cdbi/24-meta_info.t +++ b/t/cdbi/24-meta_info.t @@ -2,13 +2,10 @@ use strict; use Test::More; BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" + eval "use DBIx::Class::CDBICompat;use Time::Piece;"; + plan skip_all => "Time::Piece, Class::Trigger and DBIx::ContextualFetch required: $@" if $@; - plan skip_all => "Time::Piece required for this test" - unless eval { require Time::Piece }; - plan tests => 12; } diff --git a/t/cdbi/26-mutator.t b/t/cdbi/26-mutator.t index 7ba95bd..82049c3 100644 --- a/t/cdbi/26-mutator.t +++ b/t/cdbi/26-mutator.t @@ -5,13 +5,7 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" if $@; -} - -BEGIN { - eval "use DBD::SQLite"; - plan $@ - ? (skip_all => 'needs DBD::SQLite for testing') - : (tests => 6); + plan tests => 6; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/30-pager.t b/t/cdbi/30-pager.t index f7cb867..42c534e 100644 --- a/t/cdbi/30-pager.t +++ b/t/cdbi/30-pager.t @@ -5,10 +5,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 6); + plan tests => 6; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/68-inflate_has_a.t b/t/cdbi/68-inflate_has_a.t index 0019e29..7842f0a 100644 --- a/t/cdbi/68-inflate_has_a.t +++ b/t/cdbi/68-inflate_has_a.t @@ -3,15 +3,9 @@ use warnings; use Test::More; BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required" + eval "use DBIx::Class::CDBICompat; use DateTime 0.55; use Clone;"; + plan skip_all => "Clone, DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required" if $@; - - eval { require DateTime }; - plan skip_all => "Need DateTime for inflation tests" if $@; - - eval { require Clone }; - plan skip_all => "Need Clone for CDBICompat inflation tests" if $@; } plan tests => 6; diff --git a/t/cdbi/98-failure.t b/t/cdbi/98-failure.t index 0f584b1..918bbf5 100644 --- a/t/cdbi/98-failure.t +++ b/t/cdbi/98-failure.t @@ -9,10 +9,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 7); + plan tests => 7; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/DeepAbstractSearch/01_search.t b/t/cdbi/DeepAbstractSearch/01_search.t index 3db333e..599cec1 100644 --- a/t/cdbi/DeepAbstractSearch/01_search.t +++ b/t/cdbi/DeepAbstractSearch/01_search.t @@ -2,18 +2,10 @@ use strict; use Test::More; BEGIN { - eval "use DBIx::Class::CDBICompat;"; + eval "use DBIx::Class::CDBICompat; require Class::DBI::Plugin::DeepAbstractSearch;"; if ($@) { - plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - next; + plan (skip_all => "Class::DBI::Plugin::DeepAbstractSearch, Class::Trigger and DBIx::ContextualFetch required: $@"); } - - plan skip_all => 'needs DBD::SQLite for testing' - unless eval { require DBD::SQLite }; - - plan skip_all => 'needs Class::DBI::Plugin::DeepAbstractSearch' - unless eval { require Class::DBI::Plugin::DeepAbstractSearch }; - plan tests => 19; } diff --git a/t/cdbi/abstract/search_where.t b/t/cdbi/abstract/search_where.t index a8a2445..2fb28ff 100644 --- a/t/cdbi/abstract/search_where.t +++ b/t/cdbi/abstract/search_where.t @@ -7,10 +7,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@"); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10); + plan tests => 10; } INIT { diff --git a/t/cdbi/has_many_loads_foreign_class.t b/t/cdbi/has_many_loads_foreign_class.t index f6b30e7..e94a3ab 100644 --- a/t/cdbi/has_many_loads_foreign_class.t +++ b/t/cdbi/has_many_loads_foreign_class.t @@ -5,8 +5,7 @@ use Test::More; BEGIN { eval "use DBIx::Class::CDBICompat;"; plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@; - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 3); + plan tests => 3; } diff --git a/t/cdbi/max_min_value_of.t b/t/cdbi/max_min_value_of.t index 4b23608..a9dfc8f 100644 --- a/t/cdbi/max_min_value_of.t +++ b/t/cdbi/max_min_value_of.t @@ -9,10 +9,8 @@ BEGIN { eval "use DBIx::Class::CDBICompat;"; if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); - next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 2); + plan tests => 2; } use lib 't/cdbi/testlib'; diff --git a/t/cdbi/mk_group_accessors.t b/t/cdbi/mk_group_accessors.t index debd8d5..f7d4580 100644 --- a/t/cdbi/mk_group_accessors.t +++ b/t/cdbi/mk_group_accessors.t @@ -4,9 +4,6 @@ use Test::More; BEGIN { eval "use DBIx::Class::CDBICompat;"; plan skip_all => 'Class::Trigger and DBIx::ContextualFetch required' if $@; - - eval "use DBD::SQLite"; - plan skip_all => 'needs DBD::SQLite for testing' if $@; } INIT { diff --git a/t/cdbi/object_cache.t b/t/cdbi/object_cache.t index 896f8eb..320242f 100644 --- a/t/cdbi/object_cache.t +++ b/t/cdbi/object_cache.t @@ -7,9 +7,6 @@ BEGIN { if ($@) { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); } - - eval "use DBD::SQLite"; - plan skip_all => 'needs DBD::SQLite for testing' if $@; } INIT { diff --git a/t/cdbi/set_to_undef.t b/t/cdbi/set_to_undef.t index 47b0a35..2316bf8 100644 --- a/t/cdbi/set_to_undef.t +++ b/t/cdbi/set_to_undef.t @@ -3,10 +3,9 @@ use Test::More; use lib 't/cdbi/testlib'; BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" + eval "use DBIx::Class::CDBICompat;use DateTime 0.55;"; + plan skip_all => "DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required: $@" if $@; - plan skip_all => "DateTime required" unless eval { require DateTime }; plan tests => 2; } diff --git a/t/cdbi/set_vs_DateTime.t b/t/cdbi/set_vs_DateTime.t index 45ce621..48ae9f3 100644 --- a/t/cdbi/set_vs_DateTime.t +++ b/t/cdbi/set_vs_DateTime.t @@ -4,10 +4,9 @@ use Test::Exception; use lib 't/cdbi/testlib'; BEGIN { - eval "use DBIx::Class::CDBICompat;"; - plan skip_all => "Class::Trigger and DBIx::ContextualFetch required: $@" + eval "use DBIx::Class::CDBICompat;use DateTime 0.55;"; + plan skip_all => "DateTime 0.55, Class::Trigger and DBIx::ContextualFetch required: $@" if $@; - plan skip_all => "DateTime required" unless eval { require DateTime }; plan tests => 1; } diff --git a/t/cdbi/sweet/08pager.t b/t/cdbi/sweet/08pager.t index 07166e6..015ea98 100644 --- a/t/cdbi/sweet/08pager.t +++ b/t/cdbi/sweet/08pager.t @@ -9,8 +9,7 @@ BEGIN { plan (skip_all => 'Class::Trigger and DBIx::ContextualFetch required'); next; } - eval "use DBD::SQLite"; - plan $@ ? (skip_all => 'needs DBD::SQLite for testing') : (tests => 10); + plan tests => 10; } use lib 't/lib'; diff --git a/t/inflate/core.t b/t/inflate/core.t index 9792951..3b105ce 100644 --- a/t/inflate/core.t +++ b/t/inflate/core.t @@ -8,8 +8,8 @@ use DBICTest; my $schema = DBICTest->init_schema(); -eval { require DateTime }; -plan skip_all => "Need DateTime for inflation tests" if $@; +plan skip_all => 'Inflation tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); $schema->class('CD') ->inflate_column( 'year', { inflate => sub { DateTime->new( year => shift ) }, @@ -27,8 +27,10 @@ is( $cd->year->year, 1997, 'inflated year ok' ); is( $cd->year->month, 1, 'inflated month ok' ); -eval { $cd->year(\'year +1'); }; -ok(!$@, 'updated year using a scalarref'); +lives_ok ( + sub { $cd->year(\'year +1') }, + 'updated year using a scalarref' +); $cd->update(); $cd->discard_changes(); @@ -51,8 +53,10 @@ $cd = $rs->find(3); is( $cd->year->year, $now->year, 'deflate ok' ); # set_inflated_column test -eval { $cd->set_inflated_column('year', $now) }; -ok(!$@, 'set_inflated_column with DateTime object'); +lives_ok ( + sub { $cd->set_inflated_column('year', $now) }, + 'set_inflated_column with DateTime object' +); $cd->update; $cd = $rs->find(3); @@ -60,8 +64,10 @@ is( $cd->year->year, $now->year, 'deflate ok' ); $cd = $rs->find(3); my $before_year = $cd->year->year; -eval { $cd->set_inflated_column('year', \'year + 1') }; -ok(!$@, 'set_inflated_column to "year + 1"'); +lives_ok ( + sub { $cd->set_inflated_column('year', \'year + 1') }, + 'set_inflated_column to "year + 1"', +); $cd->update; $cd->store_inflated_column('year', \'year + 1'); @@ -72,22 +78,28 @@ is( $cd->year->year, $before_year+1, 'deflate ok' ); # store_inflated_column test $cd = $rs->find(3); -eval { $cd->store_inflated_column('year', $now) }; -ok(!$@, 'store_inflated_column with DateTime object'); +lives_ok ( + sub { $cd->store_inflated_column('year', $now) }, + 'store_inflated_column with DateTime object' +); $cd->update; is( $cd->year->year, $now->year, 'deflate ok' ); # update tests $cd = $rs->find(3); -eval { $cd->update({'year' => $now}) }; -ok(!$@, 'update using DateTime object ok'); +lives_ok ( + sub { $cd->update({'year' => $now}) }, + 'update using DateTime object ok' +); is($cd->year->year, $now->year, 'deflate ok'); $cd = $rs->find(3); $before_year = $cd->year->year; -eval { $cd->update({'year' => \'year + 1'}) }; -ok(!$@, 'update using scalarref ok'); +lives_ok ( + sub { $cd->update({'year' => \'year + 1'}) }, + 'update using scalarref ok' +); $cd = $rs->find(3); is($cd->year->year, $before_year + 1, 'deflate ok'); diff --git a/t/inflate/datetime.t b/t/inflate/datetime.t index ae8fc3b..2f4f740 100644 --- a/t/inflate/datetime.t +++ b/t/inflate/datetime.t @@ -7,11 +7,8 @@ use DBICTest; my $schema = DBICTest->init_schema(); -eval { require DateTime::Format::SQLite }; -plan $@ - ? ( skip_all => "Need DateTime::Format::SQLite for DT inflation tests" ) - : ( tests => 18 ) -; +plan skip_all => 'DT inflation tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); # inflation test my $event = $schema->resultset("Event")->find(1); @@ -74,3 +71,5 @@ is("$varchar_datetime", '2006-05-22T19:05:07', 'Correct date/time'); ## skip inflation field my $skip_inflation = $event->skip_inflation; is ("$skip_inflation", '2006-04-21 18:04:06', 'Correct date/time'); + +done_testing; diff --git a/t/inflate/datetime_determine_parser.t b/t/inflate/datetime_determine_parser.t index 380242d..802c30e 100644 --- a/t/inflate/datetime_determine_parser.t +++ b/t/inflate/datetime_determine_parser.t @@ -1,13 +1,12 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); use DBICTest; -eval { require DateTime::Format::SQLite }; -plan $@ ? ( skip_all => 'Requires DateTime::Format::SQLite' ) - : ( tests => 3 ); +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_sqlite') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_sqlite'); my $schema = DBICTest->init_schema( no_deploy => 1, # Deploying would cause an early rebless @@ -26,3 +25,4 @@ my $parser = $schema->storage->datetime_parser(); is($parser, 'DateTime::Format::SQLite', 'Got expected storage-set datetime_parser'); isa_ok($schema->storage, 'DBIx::Class::Storage::DBI::SQLite', 'storage'); +done_testing; diff --git a/t/inflate/datetime_firebird.t b/t/inflate/datetime_firebird.t index 6d52d06..572fc4e 100644 --- a/t/inflate/datetime_firebird.t +++ b/t/inflate/datetime_firebird.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use Test::Exception; @@ -16,13 +16,11 @@ Set $ENV{DBICTEST_FIREBIRD_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 -} else { - eval "use DateTime; use DateTime::Format::Strptime;"; - if ($@) { - plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing'; - } } +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_informix.t b/t/inflate/datetime_informix.t index af23410..da0cb69 100644 --- a/t/inflate/datetime_informix.t +++ b/t/inflate/datetime_informix.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use Test::Exception; @@ -14,13 +14,11 @@ if (not $dsn) { Set $ENV{DBICTEST_INFORMIX_DSN} _USER and _PASS to run this test'. Warning: This test drops and creates a table called 'event'"; EOF -} else { - eval "use DateTime; use DateTime::Format::Strptime;"; - if ($@) { - plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing'; - } } +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_mssql.t b/t/inflate/datetime_mssql.t index 44984a3..e9c003e 100644 --- a/t/inflate/datetime_mssql.t +++ b/t/inflate/datetime_mssql.t @@ -22,13 +22,11 @@ if (not ($dsn || $dsn2)) { 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN} and/or $ENV{DBICTEST_MSSQL_DSN} _USER ' .'and _PASS to run this test' . "\nWarning: This test drops and creates a table called 'track'"; -} else { - eval "use DateTime; use DateTime::Format::Strptime;"; - if ($@) { - plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing'; - } } +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_mysql.t b/t/inflate/datetime_mysql.t index 51368ad..d14ee7d 100644 --- a/t/inflate/datetime_mysql.t +++ b/t/inflate/datetime_mysql.t @@ -3,22 +3,20 @@ use warnings; use Test::More; use Test::Exception; +use Test::Warn; use lib qw(t/lib); use DBICTest; use DBICTest::Schema; +plan skip_all => 'Inflation tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_mysql') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_mysql'); + { local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ }; DBICTest::Schema->load_classes('EventTZ'); DBICTest::Schema->load_classes('EventTZDeprecated'); } -eval { require DateTime::Format::MySQL }; -plan $@ - ? ( skip_all => "Need DateTime::Format::MySQL for inflation tests") - : ( tests => 33 ) -; - my $schema = DBICTest->init_schema(); # Test "timezone" parameter @@ -56,20 +54,17 @@ foreach my $tbl (qw/EventTZ EventTZDeprecated/) { # Test floating timezone warning # We expect one warning SKIP: { - skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 1 if $ENV{DBIC_FLOATING_TZ_OK}; - local $SIG{__WARN__} = sub { - like( - shift, - qr/You're using a floating timezone, please see the documentation of DBIx::Class::InflateColumn::DateTime for an explanation/, - 'Floating timezone warning' - ); - }; - my $event_tz_floating = $schema->resultset($tbl)->create({ - starts_at => DateTime->new(year=>2007, month=>12, day=>31, ), - created_on => DateTime->new(year=>2006, month=>1, day=>31, - hour => 13, minute => 34, second => 56, ), - }); - delete $SIG{__WARN__}; + skip "ENV{DBIC_FLOATING_TZ_OK} was set, skipping", 1 if $ENV{DBIC_FLOATING_TZ_OK}; + warnings_exist ( + sub { + $schema->resultset($tbl)->create({ + starts_at => DateTime->new(year=>2007, month=>12, day=>31 ), + created_on => DateTime->new(year=>2006, month=>1, day=>31, hour => 13, minute => 34, second => 56 ), + }); + }, + qr/You're using a floating timezone, please see the documentation of DBIx::Class::InflateColumn::DateTime for an explanation/, + 'Floating timezone warning' + ); }; # This should fail to set @@ -95,3 +90,5 @@ throws_ok ( qr/invalid date format/i, "Invalid date format exception" ); + +done_testing; diff --git a/t/inflate/datetime_oracle.t b/t/inflate/datetime_oracle.t index 40fa59a..84533e8 100644 --- a/t/inflate/datetime_oracle.t +++ b/t/inflate/datetime_oracle.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); @@ -11,15 +11,9 @@ if (not ($dsn && $user && $pass)) { plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test. ' . 'Warning: This test drops and creates a table called \'track\''; } -else { - eval "use DateTime; use DateTime::Format::Oracle;"; - if ($@) { - plan skip_all => 'needs DateTime and DateTime::Format::Oracle for testing'; - } - else { - plan tests => 10; - } -} + +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'; @@ -94,6 +88,8 @@ is( $track->last_updated_at, $timestamp, 'DateTime round-trip as TIMESTAMP' ); is( int $track->last_updated_at->nanosecond, int 500_000_000, 'TIMESTAMP nanoseconds survived' ); +done_testing; + # clean up our mess END { if($schema && ($dbh = $schema->storage->dbh)) { diff --git a/t/inflate/datetime_pg.t b/t/inflate/datetime_pg.t index 2b19df4..d39496f 100644 --- a/t/inflate/datetime_pg.t +++ b/t/inflate/datetime_pg.t @@ -5,18 +5,14 @@ use Test::More; use lib qw(t/lib); use DBICTest; +plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_pg') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_pg'); + { local $SIG{__WARN__} = sub { warn @_ if $_[0] !~ /extra \=\> .+? has been deprecated/ }; DBICTest::Schema->load_classes('EventTZPg'); } -eval { require DateTime::Format::Pg }; -plan $@ - ? ( skip_all => 'Need DateTime::Format::Pg for timestamp inflation tests') - : ( tests => 6 ) -; - - my $schema = DBICTest->init_schema(); { @@ -38,3 +34,5 @@ my $schema = DBICTest->init_schema(); is($event->ts_without_tz->microsecond, $dt->microsecond, 'timestamp without time zone microseconds survived'); } + +done_testing; diff --git a/t/inflate/datetime_sybase.t b/t/inflate/datetime_sybase.t index f1ff6fc..ab64136 100644 --- a/t/inflate/datetime_sybase.t +++ b/t/inflate/datetime_sybase.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use Test::Exception; @@ -12,13 +12,11 @@ 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'"; -} else { - eval "use DateTime; use DateTime::Format::Sybase;"; - if ($@) { - plan skip_all => 'needs DateTime and DateTime::Format::Sybase for testing'; - } } +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 @storage_types = ( 'DBI::Sybase::ASE', 'DBI::Sybase::ASE::NoBindVars', @@ -46,7 +44,7 @@ for my $storage_type (@storage_types) { # minute precision ['SMALLDATETIME', 'small_dt', '2004-08-21T14:36:00.000Z'], ); - + for my $dt_type (@dt_types) { my ($type, $col, $sample_dt) = @$dt_type; diff --git a/t/inflate/datetime_sybase_asa.t b/t/inflate/datetime_sybase_asa.t index 88049be..c05f229 100644 --- a/t/inflate/datetime_sybase_asa.t +++ b/t/inflate/datetime_sybase_asa.t @@ -16,13 +16,11 @@ Set $ENV{DBICTEST_SYBASE_ASA_DSN} and/or $ENV{DBICTEST_SYBASE_ASA_ODBC_DSN} _USER and _PASS to run this test'. Warning: This test drops and creates a table called 'track'"; EOF -} else { - eval "use DateTime; use DateTime::Format::Strptime;"; - if ($@) { - plan skip_all => 'needs DateTime and DateTime::Format::Strptime for testing'; - } } +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/serialize.t b/t/inflate/serialize.t index 49cf695..87fb7ce 100644 --- a/t/inflate/serialize.t +++ b/t/inflate/serialize.t @@ -1,5 +1,5 @@ use strict; -use warnings; +use warnings; use Test::More; use lib qw(t/lib); diff --git a/t/resultset/plus_select.t b/t/resultset/plus_select.t index 171779d..0d3be3c 100644 --- a/t/resultset/plus_select.t +++ b/t/resultset/plus_select.t @@ -43,8 +43,10 @@ is_deeply ( ); SKIP: { - eval { require DateTime }; - skip "Need DateTime for +select/get_inflated_columns tests", 1 if $@; + skip ( + "+select/get_inflated_columns tests need " . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt'), + 1 + ) unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt'); $schema->class('CD')->inflate_column( 'year', { inflate => sub { DateTime->new( year => shift ) }, diff --git a/t/storage/replicated.t b/t/storage/replicated.t index 67f8618..67b6c2b 100644 --- a/t/storage/replicated.t +++ b/t/storage/replicated.t @@ -1,31 +1,32 @@ use strict; use warnings; -use lib qw(t/lib); + use Test::More; + +BEGIN { + require DBIx::Class; + plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_replicated') + unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_replicated'); +} + +use Test::Moose; use Test::Exception; -use DBICTest; use List::Util 'first'; use Scalar::Util 'reftype'; use File::Spec; use IO::Handle; +use Moose(); +use MooseX::Types(); +note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION"; -BEGIN { - eval { require Test::Moose; Test::Moose->import() }; - plan skip_all => "Need Test::Moose to run this test" if $@; - require DBIx::Class; - - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('replicated') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('replicated'); -} +use lib qw(t/lib); +use DBICTest; use_ok 'DBIx::Class::Storage::DBI::Replicated::Pool'; use_ok 'DBIx::Class::Storage::DBI::Replicated::Balancer'; use_ok 'DBIx::Class::Storage::DBI::Replicated::Replicant'; use_ok 'DBIx::Class::Storage::DBI::Replicated'; -use Moose(); -use MooseX::Types(); -note "Using Moose version $Moose::VERSION and MooseX::Types version $MooseX::Types::VERSION"; =head1 HOW TO USE