From: Peter Rabbitson Date: Tue, 10 Feb 2015 15:17:55 +0000 (+0100) Subject: Switch CDBICompat and its tests to OptDeps X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=83eef5621cc3a7b77a280b4b01f1175e9935fff6;p=dbsrgits%2FDBIx-Class-Historic.git Switch CDBICompat and its tests to OptDeps This work is a direct descendant of ilmari's c8dc7d33, even though it does not contain almost any of the original code. While the original approach was a big improvement, this commit is taking advantage of all improvements that took place in OptDep handling in earlier commits. The result (at the expense of a much much larger changeset) is a skip time of < 0.5s for the entire cdbi set ilmari++ # this revamp would not have taken place without your first nudge --- diff --git a/lib/DBIx/Class/CDBICompat.pm b/lib/DBIx/Class/CDBICompat.pm index f2bb881..f3697c2 100644 --- a/lib/DBIx/Class/CDBICompat.pm +++ b/lib/DBIx/Class/CDBICompat.pm @@ -2,22 +2,15 @@ package DBIx::Class::CDBICompat; use strict; use warnings; -use base qw/DBIx::Class::Core DBIx::Class::DB/; - -# Modules CDBICompat needs that DBIx::Class does not. -my @Extra_Modules = qw( - Class::Trigger - DBIx::ContextualFetch - Clone -); -my @didnt_load; -for my $module (@Extra_Modules) { - push @didnt_load, $module unless eval qq{require $module}; +BEGIN { + require DBIx::Class::Optional::Dependencies; + if (my $missing = DBIx::Class::Optional::Dependencies->req_missing_for('cdbicompat')) { + die "The following extra modules are required for DBIx::Class::CDBICompat: $missing\n"; + } } -__PACKAGE__->throw_exception("@{[ join ', ', @didnt_load ]} are missing and are required for CDBICompat") - if @didnt_load; +use base qw/DBIx::Class::Core DBIx::Class::DB/; __PACKAGE__->load_own_components(qw/ Constraints diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index 0ceeb19..56f04dc 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -69,9 +69,13 @@ my $dbic_reqs = { # this prevents the "skips due to forgotten deps" issue test_adhoc => { req => { + 'Class::DBI::Plugin::DeepAbstractSearch' => '0', + 'Class::DBI' => '3.000005', 'Date::Simple' => '3.03', 'YAML' => '0', 'Class::Unload' => '0.07', + 'Time::Piece' => '0', + 'Time::Piece::MySQL' => '0', }, }, @@ -146,6 +150,19 @@ my $dbic_reqs = { }, }, + cdbicompat => { + req => { + 'Class::Data::Inheritable' => '0', + 'Class::Trigger' => '0', + 'DBIx::ContextualFetch' => '0', + 'Clone' => '0.32', + }, + pod => { + title => 'DBIx::Class::CDBICompat support', + desc => 'Modules required for L' + }, + }, + test_pod => { req => { 'Test::Pod' => '1.42', @@ -203,13 +220,6 @@ my $dbic_reqs = { }, }, - test_cdbicompat => { - include => 'icdt', - req => { - 'Class::DBI::Plugin::DeepAbstractSearch' => '0', - 'Time::Piece::MySQL' => '0', - }, - }, # this is just for completeness as SQLite # is a core dep of DBIC for testing diff --git a/t/cdbi/01-columns.t b/t/cdbi/01-columns.t index 275ed4a..76bce52 100644 --- a/t/cdbi/01-columns.t +++ b/t/cdbi/01-columns.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; @@ -97,8 +99,8 @@ ok(!State->find_column('HGLAGAGlAG'), '!find_column HGLAGAGlAG'); } { - SKIP: { - skip "No column objects", 1; + { + local $TODO = "No column objects"; eval { my @grps = State->__grouper->groups_for("Huh"); }; ok $@, "Huh not in groups"; diff --git a/t/cdbi/02-Film.t b/t/cdbi/02-Film.t index 111a4f0..7a6f9e9 100644 --- a/t/cdbi/02-Film.t +++ b/t/cdbi/02-Film.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; diff --git a/t/cdbi/03-subclassing.t b/t/cdbi/03-subclassing.t index 767b341..8a73a09 100644 --- a/t/cdbi/03-subclassing.t +++ b/t/cdbi/03-subclassing.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; diff --git a/t/cdbi/04-lazy.t b/t/cdbi/04-lazy.t index ca28b07..2e37827 100644 --- a/t/cdbi/04-lazy.t +++ b/t/cdbi/04-lazy.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use Test::Warn; diff --git a/t/cdbi/06-hasa.t b/t/cdbi/06-hasa.t index 3c47caa..d191b65 100644 --- a/t/cdbi/06-hasa.t +++ b/t/cdbi/06-hasa.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use Test::Exception; use DBIx::Class::_Util 'sigwarn_silencer'; diff --git a/t/cdbi/08-inheritcols.t b/t/cdbi/08-inheritcols.t index 5550e59..bc9b90a 100644 --- a/t/cdbi/08-inheritcols.t +++ b/t/cdbi/08-inheritcols.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/09-has_many.t b/t/cdbi/09-has_many.t index 0c751a0..a19500a 100644 --- a/t/cdbi/09-has_many.t +++ b/t/cdbi/09-has_many.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/11-triggers.t b/t/cdbi/11-triggers.t index c944248..cd322e5 100644 --- a/t/cdbi/11-triggers.t +++ b/t/cdbi/11-triggers.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/12-filter.t b/t/cdbi/12-filter.t index 9a715ed..de68fa1 100644 --- a/t/cdbi/12-filter.t +++ b/t/cdbi/12-filter.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/13-constraint.t b/t/cdbi/13-constraint.t index 4191fe5..ba9f654 100644 --- a/t/cdbi/13-constraint.t +++ b/t/cdbi/13-constraint.t @@ -1,6 +1,10 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; +use Test::Exception; use lib 't/cdbi/testlib'; use Film; @@ -58,10 +62,10 @@ ok $fred, "Got fred"; like $@, qr/fails.*constraint/, "Fails listref constraint"; my $ok = eval { Film->create({ Rating => 'U' }) }; is $@, '', "Can create with rating U"; - SKIP: { - skip "No column objects", 2; - ok +Film->find_column('rating')->is_constrained, "Rating is constrained"; - ok +Film->find_column('director')->is_constrained, "Director is not"; + { + local $TODO = "No column objects"; + lives_ok { Film->find_column('rating')->is_constrained || die } "Rating is constrained"; + lives_ok { Film->find_column('director')->is_constrained || die } "Director is not"; } } diff --git a/t/cdbi/14-might_have.t b/t/cdbi/14-might_have.t index 73318ac..52a2abd 100644 --- a/t/cdbi/14-might_have.t +++ b/t/cdbi/14-might_have.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/15-accessor.t b/t/cdbi/15-accessor.t index f5c0099..85f8464 100644 --- a/t/cdbi/15-accessor.t +++ b/t/cdbi/15-accessor.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/16-reserved.t b/t/cdbi/16-reserved.t index e54d0ae..ce8a4b3 100644 --- a/t/cdbi/16-reserved.t +++ b/t/cdbi/16-reserved.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/18-has_a.t b/t/cdbi/18-has_a.t index e1deb09..dfb5819 100644 --- a/t/cdbi/18-has_a.t +++ b/t/cdbi/18-has_a.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use Test::Exception; use DBIx::Class::_Util 'sigwarn_silencer'; diff --git a/t/cdbi/19-set_sql.t b/t/cdbi/19-set_sql.t index 41040af..a981810 100644 --- a/t/cdbi/19-set_sql.t +++ b/t/cdbi/19-set_sql.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/21-iterator.t b/t/cdbi/21-iterator.t index f49bf68..14a1b30 100644 --- a/t/cdbi/21-iterator.t +++ b/t/cdbi/21-iterator.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/22-deflate_order.t b/t/cdbi/22-deflate_order.t index d4e9935..71d8d7d 100644 --- a/t/cdbi/22-deflate_order.t +++ b/t/cdbi/22-deflate_order.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( cdbicompat test_rdbms_mysql Time::Piece::MySQL>=0 ); + $| = 1; use warnings; use strict; @@ -5,10 +7,6 @@ use strict; use Test::More; use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs - -eval { require Time::Piece::MySQL } - or plan skip_all => 'Time::Piece::MySQL required for this test'; use_ok ('Log'); diff --git a/t/cdbi/22-self_referential.t b/t/cdbi/22-self_referential.t index 1538ef4..43ad050 100644 --- a/t/cdbi/22-self_referential.t +++ b/t/cdbi/22-self_referential.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/23-cascade.t b/t/cdbi/23-cascade.t index 79fed22..809f458 100644 --- a/t/cdbi/23-cascade.t +++ b/t/cdbi/23-cascade.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use Data::Dumper; diff --git a/t/cdbi/24-meta_info.t b/t/cdbi/24-meta_info.t index f2fc57f..703e3fd 100644 --- a/t/cdbi/24-meta_info.t +++ b/t/cdbi/24-meta_info.t @@ -1,14 +1,11 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( cdbicompat Time::Piece>=0 ); + use strict; use warnings; + use Test::More; use Test::Warn; -use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs - -eval { require Time::Piece } - or plan skip_all => 'Time::Piece required for this test'; - package Temp::DBI; use base qw(DBIx::Class::CDBICompat); Temp::DBI->columns(All => qw(id date)); diff --git a/t/cdbi/26-mutator.t b/t/cdbi/26-mutator.t index a203059..54a4229 100644 --- a/t/cdbi/26-mutator.t +++ b/t/cdbi/26-mutator.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/30-pager.t b/t/cdbi/30-pager.t index 9ee838a..d192d97 100644 --- a/t/cdbi/30-pager.t +++ b/t/cdbi/30-pager.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/68-inflate_has_a.t b/t/cdbi/68-inflate_has_a.t index 246a319..ed4f4fe 100644 --- a/t/cdbi/68-inflate_has_a.t +++ b/t/cdbi/68-inflate_has_a.t @@ -1,14 +1,11 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( icdt cdbicompat ); + use strict; use warnings; -use Test::More; -use lib qw(t/cdbi/testlib); -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs - -BEGIN { - eval { require DateTime; DateTime->VERSION(0.55) } - or plan skip_all => 'DateTime 0.55 required for this test'; -} +use Test::More; +use lib 't/lib'; +use DBICTest; my $schema = DBICTest->init_schema(); diff --git a/t/cdbi/70_implicit_inflate.t b/t/cdbi/70_implicit_inflate.t index 5c92f75..4a3fd6f 100644 --- a/t/cdbi/70_implicit_inflate.t +++ b/t/cdbi/70_implicit_inflate.t @@ -1,4 +1,4 @@ -use DBIx::Class::Optional::Dependencies -skip_all_without => qw( rdbms_sqlite icdt ); +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( cdbicompat rdbms_sqlite icdt ); use strict; use warnings; diff --git a/t/cdbi/71_column_object.t b/t/cdbi/71_column_object.t index a97960f..e00820b 100644 --- a/t/cdbi/71_column_object.t +++ b/t/cdbi/71_column_object.t @@ -1,16 +1,13 @@ +# Columns in CDBI could be defined as Class::DBI::Column objects rather than +# or as well as with __PACKAGE__->columns(); +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( cdbicompat Class::DBI>=3.000005 ); + use strict; use warnings; use Test::More; -use lib 't/cdbi/testlib'; - -# Columns in CDBI could be defined as Class::DBI::Column objects rather than -# or as well as with __PACKAGE__->columns(); -BEGIN { - eval { require Class::DBI and Class::DBI->VERSION('3.0.5') } - or plan skip_all => 'The tested functionality is only available in Class::DBI >= 3.0.5' -} +use lib 't/cdbi/testlib'; use ColumnObject; ok(ColumnObject->can('db_Main'), 'set_db()'); diff --git a/t/cdbi/98-failure.t b/t/cdbi/98-failure.t index 1a42e03..9a993c4 100644 --- a/t/cdbi/98-failure.t +++ b/t/cdbi/98-failure.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; #---------------------------------------------------------------------- diff --git a/t/cdbi/DeepAbstractSearch/01_search.t b/t/cdbi/DeepAbstractSearch/01_search.t index 95ad021..f4911c7 100644 --- a/t/cdbi/DeepAbstractSearch/01_search.t +++ b/t/cdbi/DeepAbstractSearch/01_search.t @@ -1,14 +1,12 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( cdbicompat Class::DBI::Plugin::DeepAbstractSearch>=0 ); + use strict; use warnings; -use Test::More; -use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs +use Test::More; -BEGIN { - eval { require Class::DBI::Plugin::DeepAbstractSearch } - or plan skip_all => 'Class::DBI::Plugin::DeepAbstractSearch required for this test'; -} +use lib 't/lib'; +use DBICTest; my $DB = DBICTest->_sqlite_dbname(sqlite_use_file => 1);; diff --git a/t/cdbi/abstract/search_where.t b/t/cdbi/abstract/search_where.t index 8c4c629..2c15ecc 100644 --- a/t/cdbi/abstract/search_where.t +++ b/t/cdbi/abstract/search_where.t @@ -1,8 +1,10 @@ -use Test::More; +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; use strict; use warnings; +use Test::More; + use lib 't/cdbi/testlib'; use Film; diff --git a/t/cdbi/columns_as_hashes.t b/t/cdbi/columns_as_hashes.t index cddb264..9731ae3 100644 --- a/t/cdbi/columns_as_hashes.t +++ b/t/cdbi/columns_as_hashes.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use Test::Warn; diff --git a/t/cdbi/columns_dont_override_custom_accessors.t b/t/cdbi/columns_dont_override_custom_accessors.t index 27a96fd..5748b6e 100644 --- a/t/cdbi/columns_dont_override_custom_accessors.t +++ b/t/cdbi/columns_dont_override_custom_accessors.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/construct.t b/t/cdbi/construct.t index 103877d..d10e6a1 100644 --- a/t/cdbi/construct.t +++ b/t/cdbi/construct.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/copy.t b/t/cdbi/copy.t index d87b73e..f587ae0 100644 --- a/t/cdbi/copy.t +++ b/t/cdbi/copy.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/early_column_heisenbug.t b/t/cdbi/early_column_heisenbug.t index 859d43d..e91b401 100644 --- a/t/cdbi/early_column_heisenbug.t +++ b/t/cdbi/early_column_heisenbug.t @@ -1,11 +1,10 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; use Test::More; -use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs - { package Thing; use base qw(DBIx::Class::CDBICompat); diff --git a/t/cdbi/has_many_loads_foreign_class.t b/t/cdbi/has_many_loads_foreign_class.t index bba66e8..5485972 100644 --- a/t/cdbi/has_many_loads_foreign_class.t +++ b/t/cdbi/has_many_loads_foreign_class.t @@ -1,15 +1,17 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; -use Test::More; -use Class::Inspector (); +use Test::More; use lib 't/cdbi/testlib'; use Director; -# Test that has_many() will load the foreign class. +# Test that has_many() will load the foreign class +require Class::Inspector; ok !Class::Inspector->loaded( 'Film' ); -ok eval { Director->has_many( films => 'Film' ); 1; } || diag $@; +ok eval { Director->has_many( films => 'Film' ); 1; } or diag $@; my $shan_hua = Director->create({ Name => "Shan Hua", diff --git a/t/cdbi/hasa_without_loading.t b/t/cdbi/hasa_without_loading.t index 5f92df2..3b92c4d 100644 --- a/t/cdbi/hasa_without_loading.t +++ b/t/cdbi/hasa_without_loading.t @@ -1,9 +1,11 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs package Foo; diff --git a/t/cdbi/max_min_value_of.t b/t/cdbi/max_min_value_of.t index 5dc2f1a..aba3821 100644 --- a/t/cdbi/max_min_value_of.t +++ b/t/cdbi/max_min_value_of.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; #---------------------------------------------------------------------- diff --git a/t/cdbi/mk_group_accessors.t b/t/cdbi/mk_group_accessors.t index b3e850a..5fc1994 100644 --- a/t/cdbi/mk_group_accessors.t +++ b/t/cdbi/mk_group_accessors.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/multi_column_set.t b/t/cdbi/multi_column_set.t index 8ca3bcf..1f1d1ac 100644 --- a/t/cdbi/multi_column_set.t +++ b/t/cdbi/multi_column_set.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/object_cache.t b/t/cdbi/object_cache.t index 22841c4..db0dc06 100644 --- a/t/cdbi/object_cache.t +++ b/t/cdbi/object_cache.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; $| = 1; diff --git a/t/cdbi/retrieve_from_sql_with_limit.t b/t/cdbi/retrieve_from_sql_with_limit.t index f362896..4045361 100644 --- a/t/cdbi/retrieve_from_sql_with_limit.t +++ b/t/cdbi/retrieve_from_sql_with_limit.t @@ -1,5 +1,8 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; + use Test::More; use lib 't/cdbi/testlib'; diff --git a/t/cdbi/set_to_undef.t b/t/cdbi/set_to_undef.t index 03fe0ca..81f6f8a 100644 --- a/t/cdbi/set_to_undef.t +++ b/t/cdbi/set_to_undef.t @@ -1,15 +1,10 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( icdt cdbicompat ); + use strict; use warnings; -use Test::More; +use Test::More; use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs - -BEGIN { - eval { require DateTime; DateTime->VERSION(0.55) } - or plan skip_all => 'DateTime 0.55 required for this test'; -} - # Don't use Test::NoWarnings because of an unrelated DBD::SQLite warning. my @warnings; diff --git a/t/cdbi/set_vs_DateTime.t b/t/cdbi/set_vs_DateTime.t index 08fe4c9..e246b13 100644 --- a/t/cdbi/set_vs_DateTime.t +++ b/t/cdbi/set_vs_DateTime.t @@ -1,15 +1,12 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( icdt cdbicompat ); + use strict; use warnings; + use Test::More; use Test::Exception; use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite (); # this will issue the necessary SKIPs on missing reqs - -BEGIN { - eval { require DateTime; DateTime->VERSION(0.55) } - or plan skip_all => 'DateTime 0.55 required for this test'; -} { package Thing; diff --git a/t/cdbi/sweet/08pager.t b/t/cdbi/sweet/08pager.t index f645276..e14c4fa 100644 --- a/t/cdbi/sweet/08pager.t +++ b/t/cdbi/sweet/08pager.t @@ -1,10 +1,12 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'cdbicompat'; + use strict; use warnings; use Test::More; -use lib 't/cdbi/testlib'; -use DBIC::Test::SQLite; +use lib 't/lib'; +use DBICTest; DBICTest::Schema::CD->load_components(qw/CDBICompat CDBICompat::Pager/); diff --git a/t/cdbi/testlib/DBIC/Test/SQLite.pm b/t/cdbi/testlib/DBIC/Test/SQLite.pm index 905ed88..76822cd 100644 --- a/t/cdbi/testlib/DBIC/Test/SQLite.pm +++ b/t/cdbi/testlib/DBIC/Test/SQLite.pm @@ -1,6 +1,9 @@ package # hide from PAUSE DBIC::Test::SQLite; +use strict; +use warnings; + =head1 NAME DBIx::Class::Test::SQLite - Base class for running Class::DBI tests against DBIx::Class compat layer, shamelessly ripped from Class::DBI::Test::SQLite @@ -31,11 +34,6 @@ table, and tie it to the class. =cut -use strict; -use warnings; - -use Test::More; - # adding implicit search criteria to the iterator will alter the test # mechanics - leave everything as-is instead, and hope SQLite won't # change too much @@ -44,11 +42,6 @@ BEGIN { $ENV{DBIC_SHUFFLE_UNORDERED_RESULTSETS} = 0 } use lib 't/lib'; use DBICTest; -BEGIN { - eval { require DBIx::Class::CDBICompat } - or plan skip_all => 'Class::DBI required for this test'; -} - use base qw/DBIx::Class/; __PACKAGE__->load_components(qw/CDBICompat Core DB/); diff --git a/t/cdbi/testlib/MyBase.pm b/t/cdbi/testlib/MyBase.pm index 1fc77d0..1fe9317 100644 --- a/t/cdbi/testlib/MyBase.pm +++ b/t/cdbi/testlib/MyBase.pm @@ -11,33 +11,13 @@ use DBICTest; use base qw(DBIx::Class::CDBICompat); -our $dbh; - -my $err; -if (! $ENV{DBICTEST_MYSQL_DSN} ) { - $err = 'Set $ENV{DBICTEST_MYSQL_DSN}, _USER and _PASS to run this test'; -} -elsif ( ! DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql') ) { - $err = 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') -} - -if ($err) { - my $t = eval { Test::Builder->new }; - if ($t and ! $t->current_test) { - $t->skip_all ($err); - } - else { - die "$err\n"; - } -} - my @connect = (@ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}, { PrintError => 0}); # this is only so we grab a lock on mysql { my $x = DBICTest::Schema->connect(@connect); } -$dbh = DBI->connect(@connect) or die DBI->errstr; +our $dbh = DBI->connect(@connect) or die DBI->errstr; my @table; END {