From: Peter Rabbitson Date: Tue, 5 Nov 2013 08:17:52 +0000 (+0100) Subject: Make sure DBICTest is always loaded first (purely bookkeep) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=5e7249645ea75d5a9d25f1fdf8a42e0536b03f4e;p=dbsrgits%2FDBIx-Class-Historic.git Make sure DBICTest is always loaded first (purely bookkeep) --- diff --git a/t/106dbic_carp.t b/t/106dbic_carp.t index e6710d8..f6bd91d 100644 --- a/t/106dbic_carp.t +++ b/t/106dbic_carp.t @@ -7,9 +7,9 @@ BEGIN { $ENV{DBIC_TRACE} = 0 } use Test::More; use Test::Warn; use Test::Exception; -use DBIx::Class::Carp; use lib 't/lib'; use DBICTest; +use DBIx::Class::Carp; { sub DBICTest::DBICCarp::frobnicate { diff --git a/t/53lean_startup.t b/t/53lean_startup.t index 4319940..311fa24 100644 --- a/t/53lean_startup.t +++ b/t/53lean_startup.t @@ -152,7 +152,12 @@ BEGIN { # and do full populate() as well, just in case - shouldn't add new stuff { local $ENV{DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER}; - require DBICTest; + { + # in general we do not want DBICTest to load before sqla, but it is + # ok to cheat here + local $INC{'SQL/Abstract.pm'}; + require DBICTest; + } my $s = DBICTest->init_schema; is ($s->resultset('Artist')->find(1)->name, 'Caterwauler McCrae'); assert_no_missing_expected_requires(); diff --git a/t/73oracle_hq.t b/t/73oracle_hq.t index 8189479..c09cbfd 100644 --- a/t/73oracle_hq.t +++ b/t/73oracle_hq.t @@ -6,11 +6,6 @@ use Test::More; use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest::RunMode; -use DBIC::SqlMakerTest; - -use DBIx::Class::SQLMaker::LimitDialects; -my $ROWS = DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype, -my $TOTAL = DBIx::Class::SQLMaker::LimitDialects->__total_bindtype, $ENV{NLS_SORT} = "BINARY"; $ENV{NLS_COMP} = "BINARY"; @@ -41,6 +36,11 @@ BEGIN { use DBICTest; use DBICTest::Schema; +use DBIC::SqlMakerTest; + +use DBIx::Class::SQLMaker::LimitDialects; +my $ROWS = DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype, +my $TOTAL = DBIx::Class::SQLMaker::LimitDialects->__total_bindtype, my $schema = DBICTest::Schema->connect($dsn, $user, $pass); diff --git a/t/746mssql.t b/t/746mssql.t index b57d218..57c44fb 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -4,14 +4,15 @@ use warnings; use Test::More; use Test::Exception; use Try::Tiny; -use DBIx::Class::SQLMaker::LimitDialects; + 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; use DBIC::SqlMakerTest; - -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 DBIx::Class::SQLMaker::LimitDialects; my $OFFSET = DBIx::Class::SQLMaker::LimitDialects->__offset_bindtype; my $TOTAL = DBIx::Class::SQLMaker::LimitDialects->__total_bindtype; diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index a185763..8988db9 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -18,6 +18,25 @@ BEGIN { } } +use Module::Runtime 'module_notional_filename'; +BEGIN { + for my $mod (qw( DBIC::SqlMakerTest SQL::Abstract )) { + if ( $INC{ module_notional_filename($mod) } ) { + # FIXME this does not seem to work in BEGIN - why?! + #require Carp; + #$Carp::Internal{ (__PACKAGE__) }++; + #Carp::croak( __PACKAGE__ . " must be loaded before $mod" ); + + my ($fr, @frame) = 1; + while (@frame = caller($fr++)) { + last if $frame[1] !~ m|^t/lib/DBICTest|; + } + + die __PACKAGE__ . " must be loaded before $mod (or modules using $mod) at $frame[1] line $frame[2]\n"; + } + } +} + use DBICTest::RunMode; use DBICTest::Schema; use DBICTest::Util::LeakTracer qw/populate_weakregistry assert_empty_weakregistry/; diff --git a/t/prefetch/double_prefetch.t b/t/prefetch/double_prefetch.t index 1e5ff10..d4b50aa 100644 --- a/t/prefetch/double_prefetch.t +++ b/t/prefetch/double_prefetch.t @@ -3,8 +3,8 @@ use strict; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); diff --git a/t/prefetch/join_type.t b/t/prefetch/join_type.t index e58af4f..ac839f0 100644 --- a/t/prefetch/join_type.t +++ b/t/prefetch/join_type.t @@ -3,8 +3,8 @@ use strict; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); diff --git a/t/prefetch/o2m_o2m_order_by_with_limit.t b/t/prefetch/o2m_o2m_order_by_with_limit.t index 75dda03..b8a4477 100644 --- a/t/prefetch/o2m_o2m_order_by_with_limit.t +++ b/t/prefetch/o2m_o2m_order_by_with_limit.t @@ -4,8 +4,8 @@ use warnings; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; +use DBIC::SqlMakerTest; use DBIx::Class::SQLMaker::LimitDialects; my ($ROWS, $OFFSET) = ( diff --git a/t/resultset/bind_attr.t b/t/resultset/bind_attr.t index 3d8d1cd..d93dcd1 100644 --- a/t/resultset/bind_attr.t +++ b/t/resultset/bind_attr.t @@ -3,10 +3,9 @@ use warnings; use Test::More; use lib qw(t/lib); +use DBICTest; use DBIC::SqlMakerTest; -use_ok('DBICTest'); - my $schema = DBICTest->init_schema; my $where_bind = { diff --git a/t/search/distinct.t b/t/search/distinct.t index 7f6eb22..07ac209 100644 --- a/t/search/distinct.t +++ b/t/search/distinct.t @@ -4,8 +4,8 @@ use warnings; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); diff --git a/t/search/related_has_many.t b/t/search/related_has_many.t index a359b4e..1834d53 100644 --- a/t/search/related_has_many.t +++ b/t/search/related_has_many.t @@ -4,8 +4,8 @@ use warnings; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); diff --git a/t/search/related_strip_prefetch.t b/t/search/related_strip_prefetch.t index 19d534e..76336b1 100644 --- a/t/search/related_strip_prefetch.t +++ b/t/search/related_strip_prefetch.t @@ -4,8 +4,8 @@ use warnings; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; +use DBIC::SqlMakerTest; use DBIx::Class::SQLMaker::LimitDialects; my $ROWS = DBIx::Class::SQLMaker::LimitDialects->__rows_bindtype; diff --git a/t/search/select_chains.t b/t/search/select_chains.t index e57fc26..257b0b3 100644 --- a/t/search/select_chains.t +++ b/t/search/select_chains.t @@ -4,9 +4,8 @@ use warnings; use Test::More; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; - +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); diff --git a/t/search/select_chains_unbalanced.t b/t/search/select_chains_unbalanced.t index b803c0f..d742fd6 100644 --- a/t/search/select_chains_unbalanced.t +++ b/t/search/select_chains_unbalanced.t @@ -5,9 +5,8 @@ use Test::More; use Test::Exception; use lib qw(t/lib); -use DBIC::SqlMakerTest; use DBICTest; - +use DBIC::SqlMakerTest; my $schema = DBICTest->init_schema(); diff --git a/t/sqlmaker/core.t b/t/sqlmaker/core.t index 7312c98..57cf480 100644 --- a/t/sqlmaker/core.t +++ b/t/sqlmaker/core.t @@ -5,10 +5,9 @@ use Test::More; use Test::Exception; use lib qw(t/lib); +use DBICTest; use DBIC::SqlMakerTest; -use_ok('DBICTest'); - my $schema = DBICTest->init_schema(no_deploy => 1); my $sql_maker = $schema->storage->sql_maker; diff --git a/t/sqlmaker/core_quoted.t b/t/sqlmaker/core_quoted.t index a8a4af5..53ce03b 100644 --- a/t/sqlmaker/core_quoted.t +++ b/t/sqlmaker/core_quoted.t @@ -4,10 +4,9 @@ use warnings; use Test::More; use lib qw(t/lib); +use DBICTest; use DBIC::SqlMakerTest; -use_ok('DBICTest'); - my $schema = DBICTest->init_schema(); my $sql_maker = $schema->storage->sql_maker; diff --git a/t/sqlmaker/nest_deprec.t b/t/sqlmaker/nest_deprec.t index 98f1157..f00443a 100644 --- a/t/sqlmaker/nest_deprec.t +++ b/t/sqlmaker/nest_deprec.t @@ -5,10 +5,9 @@ use Test::More; use Test::Warn; use lib qw(t/lib); +use DBICTest; use DBIC::SqlMakerTest; -use_ok('DBICTest'); - my $schema = DBICTest->init_schema(); my $sql_maker = $schema->storage->sql_maker; diff --git a/t/sqlmaker/quotes/quotes.t b/t/sqlmaker/quotes/quotes.t index 1566a7d..3fbc94c 100644 --- a/t/sqlmaker/quotes/quotes.t +++ b/t/sqlmaker/quotes/quotes.t @@ -4,11 +4,10 @@ use warnings; use Test::More; use lib qw(t/lib); +use DBICTest; use DBIC::SqlMakerTest; +use DBIC::DebugObj; - -use_ok('DBICTest'); -use_ok('DBIC::DebugObj'); my $schema = DBICTest->init_schema(); $schema->storage->sql_maker->quote_char('`'); diff --git a/t/sqlmaker/quotes/quotes_newstyle.t b/t/sqlmaker/quotes/quotes_newstyle.t index c122517..900a68a 100644 --- a/t/sqlmaker/quotes/quotes_newstyle.t +++ b/t/sqlmaker/quotes/quotes_newstyle.t @@ -4,10 +4,9 @@ use warnings; use Test::More; use lib qw(t/lib); +use DBICTest; use DBIC::SqlMakerTest; - -use_ok('DBICTest'); -use_ok('DBIC::DebugObj'); +use DBIC::DebugObj; my $schema = DBICTest->init_schema();