From: Peter Rabbitson Date: Sun, 1 Nov 2015 12:08:12 +0000 (+0100) Subject: Fix failures and protect the suite from spurious VERSION-related warnings X-Git-Tag: v0.082821~5 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8bb84304dfb07775192935755bdf0a986fdc181d;p=dbsrgits%2FDBIx-Class.git Fix failures and protect the suite from spurious VERSION-related warnings A new SQL::Translator devrel missed a s/_// line and made several tests fail Fix t/752sqlite.t and t/icdt/offline_pg.t, and also add an obnoxious CI mode to ensure we will not fall prey to this again --- diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index 6dd9562..6ee81a8 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -4,7 +4,11 @@ package # hide from PAUSE use warnings; use strict; -use constant SPURIOUS_VERSION_CHECK_WARNINGS => ($] < 5.010 ? 1 : 0); +use constant SPURIOUS_VERSION_CHECK_WARNINGS => ( + ( $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY} or $] < 5.010 ) + ? 1 + : 0 +); BEGIN { package # hide from pause diff --git a/t/752sqlite.t b/t/752sqlite.t index 16446be..d162270 100644 --- a/t/752sqlite.t +++ b/t/752sqlite.t @@ -11,6 +11,10 @@ use lib qw(t/lib); use DBICTest; use DBIx::Class::_Util qw( sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_lt ); +# make one deploy() round before we load anything else - need this in order +# to prime SQLT if we are using it (deep depchain is deep) +DBICTest->init_schema( no_populate => 1 ); + # check that we work somewhat OK with braindead SQLite transaction handling # # As per https://metacpan.org/source/ADAMK/DBD-SQLite-1.37/lib/DBD/SQLite.pm#L921 @@ -18,8 +22,6 @@ use DBIx::Class::_Util qw( sigwarn_silencer modver_gt_or_eq modver_gt_or_eq_and_ # # However DBD::SQLite 1.38_02 seems to fix this, with an accompanying test: # https://metacpan.org/source/ADAMK/DBD-SQLite-1.38_02/t/54_literal_txn.t - -require DBD::SQLite; my $lit_txn_todo = modver_gt_or_eq('DBD::SQLite', '1.38_02') ? undef : "DBD::SQLite before 1.38_02 is retarded wrt detecting literal BEGIN/COMMIT statements" diff --git a/t/admin/10script.t b/t/admin/10script.t index 9414b84..d8acf4a 100644 --- a/t/admin/10script.t +++ b/t/admin/10script.t @@ -2,6 +2,12 @@ use strict; use warnings; +BEGIN { + # just in case the user env has stuff in it + delete $ENV{JSON_ANY_ORDER}; + delete $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY}; +} + use Test::More; use Config; use File::Spec; diff --git a/t/inflate/datetime_pg.t b/t/inflate/datetime_pg.t index c02e9f8..7a30e42 100644 --- a/t/inflate/datetime_pg.t +++ b/t/inflate/datetime_pg.t @@ -14,6 +14,10 @@ DBICTest::Schema->load_classes('EventTZPg'); my $schema = DBICTest->init_schema(); +# this may generate warnings under certain CI flags, hence do it outside of +# the warnings_are below +my $dt = DateTime->new( year => 2000, time_zone => "America/Chicago" ); + warnings_are { my $event = $schema->resultset("EventTZPg")->find(1); $event->update({created_on => '2009-01-15 17:00:00+00'}); diff --git a/t/lib/DBICTest/RunMode.pm b/t/lib/DBICTest/RunMode.pm index f1e5544..1e31436 100644 --- a/t/lib/DBICTest/RunMode.pm +++ b/t/lib/DBICTest/RunMode.pm @@ -13,6 +13,18 @@ BEGIN { die __PACKAGE__ . " must be loaded before DBIx::Class (or modules using DBIx::Class) at $frame[1] line $frame[2]\n"; } + + if ( $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY} ) { + my $ov = UNIVERSAL->can("VERSION"); + + require Carp; + + no warnings 'redefine'; + *UNIVERSAL::VERSION = sub { + Carp::carp( 'Argument "blah bleh bloh" isn\'t numeric in subroutine entry' ); + &$ov; + }; + } } use Path::Class qw/file dir/; diff --git a/xt/standalone_testschema_resultclasses.t b/xt/standalone_testschema_resultclasses.t index 7ed0381..f0dd2ac 100644 --- a/xt/standalone_testschema_resultclasses.t +++ b/xt/standalone_testschema_resultclasses.t @@ -1,6 +1,8 @@ use warnings; use strict; +BEGIN { delete $ENV{DBICTEST_VERSION_WARNS_INDISCRIMINATELY} } + use DBIx::Class::_Util 'sigwarn_silencer'; use if DBIx::Class::_ENV_::BROKEN_FORK, 'threads';