From: Peter Rabbitson Date: Fri, 17 Oct 2014 09:35:46 +0000 (+0200) Subject: Add import-time-skip support to OptDeps, switch most tests over to that X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=cb551b07;p=dbsrgits%2FDBIx-Class-Historic.git Add import-time-skip support to OptDeps, switch most tests over to that This is the meat of this refactor, inspired by multiple parties complaining (with good reason) about the sluggishness of our skip_all()s, and by groundwork in both c8dc7d333 and 2c2bc4e5 (both never applied - the former is superseded by a more direct approach and the latter being too intrusive with too little benefit after the refactor) Only tests with unambiguous skips were switched over - later commits will address multi-rdbms loops in a different manner. The loss of skip-time warnings "this test creates tables blah and blah" was deliberate, and due to several reasons *) They are displayed at the wrong time *) They are not well sycnrhonized with what the actual test does *) Some time this year all table names will switch to dbictest_-prefixing All in all the thinking is that nothing of value is lost, and the changeset is greatly simplified as a result. The loading before strict/warning in tests is actually significant. It appears that in "all deps fail" cases the speedup of not loading strictures is quite significant (demonstrated below difference on WiP CDBICompat streamlining): strictures first: Files=43, Tests=0, 1 wallclock secs ( 0.14 usr 0.08 sys + 0.35 cusr 0.15 csys = 0.72 CPU) optdeps first: Files=43, Tests=0, 1 wallclock secs ( 0.13 usr 0.06 sys + 0.14 cusr 0.11 csys = 0.44 CPU) --- diff --git a/Changes b/Changes index c7300e5..edfbff9 100644 --- a/Changes +++ b/Changes @@ -9,6 +9,8 @@ Revision history for DBIx::Class timeout lock-prone. * Misc + - Skip tests in a way more intelligent and speedy manner when optional + dependencies are missing - Make the Optional::Dependencies error messages cpanm-friendly - Incompatibly change values (not keys) of the hash returned by Optional::Dependencies::req_group_list (no known users in the wild) diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index aee78d0..cca513c 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -1,9 +1,15 @@ package DBIx::Class::Optional::Dependencies; -use warnings; -use strict; - -use Carp; +### This may look crazy, but it in fact tangibly ( by 50(!)% ) shortens +# the skip-test time when everything requested is unavailable +use if $ENV{RELEASE_TESTING} => 'warnings'; +use if $ENV{RELEASE_TESTING} => 'strict'; + +sub croak { + require Carp; + Carp::croak(@_); +}; +### # NO EXTERNAL NON-5.8.1 CORE DEPENDENCIES EVER (e.g. C::A::G) # This module is to be loaded by Makefile.PM on a pristine system @@ -95,6 +101,7 @@ my $dbic_reqs = { req => { 'Test::Pod' => '1.42', }, + release_testing_mandatory => 1, }, test_podcoverage => { @@ -102,6 +109,7 @@ my $dbic_reqs = { 'Test::Pod::Coverage' => '1.08', 'Pod::Coverage' => '0.20', }, + release_testing_mandatory => 1, }, test_whitespace => { @@ -109,12 +117,14 @@ my $dbic_reqs = { 'Test::EOL' => '1.0', 'Test::NoTabs' => '0.9', }, + release_testing_mandatory => 1, }, test_strictures => { req => { 'Test::Strict' => '0.20', }, + release_testing_mandatory => 1, }, test_prettydebug => { @@ -589,6 +599,27 @@ sub import { print "\n"; exit 0; } + elsif ($action eq '-skip_all_without') { + + # sanity check - make sure ->current_test is 0 and no plan has been declared + do { + local $@; + defined eval { + Test::Builder->new->current_test + or + Test::Builder->new->has_plan + }; + } and croak("Unable to invoke -skip_all_without after testing has started"); + + if ( my $missing = $class->req_missing_for(\@_) ) { + + die ("\nMandatory requirements not satisfied during release-testing: $missing\n\n") + if $ENV{RELEASE_TESTING} and $class->_groups_to_reqs(\@_)->{release_testing_mandatory}; + + print "1..0 # SKIP requirements not satisfied: $missing\n"; + exit 0; + } + } elsif ($action =~ /^-/) { croak "Unknown import-time action '$action'"; } @@ -822,6 +853,8 @@ sub _groups_to_reqs { $ret->{effective_modreqs_differ} ||= !!$some_envs_missing; $ret->{modreqs_fully_documented} &&= !!$dbic_reqs->{$group}{pod}; + + $ret->{release_testing_mandatory} ||= !!$dbic_reqs->{$group}{release_testing_mandatory}; } return $ret; @@ -1013,6 +1046,38 @@ EOC Even though this module is not an L, it recognizes several C supplied to its C method. +=head2 -skip_all_without + +=over + +=item Arguments: @group_names + +=back + +A convenience wrapper for use during testing: +EOC + + push @chunks, " use $class -skip_all_without => qw(admin test_rdbms_mysql);"; + + push @chunks, 'Roughly equivalent to the following code:'; + + push @chunks, sprintf <<'EOS', ($class) x 2; + + BEGIN { + require %s; + if ( my $missing = %s->req_missing_for(\@group_names_) ) { + print "1..0 # SKIP requirements not satisfied: $missing\n"; + exit 0; + } + } +EOS + + push @chunks, <<'EOC'; + +It also takes into account the C environment variable and +behaves like L for any requirement groups marked as +C. + =head2 -die_without =over diff --git a/t/105view_deps.t b/t/105view_deps.t index 21aa92b..bf470be 100644 --- a/t/105view_deps.t +++ b/t/105view_deps.t @@ -1,4 +1,4 @@ -#!/usr/bin/perl +use DBIx::Class::Optional::Dependencies -skip_all_without => 'deploy'; use strict; use warnings; @@ -11,15 +11,6 @@ use DBICTest; use ViewDeps; 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'); - #################### SANITY my $view = DBIx::Class::ResultSource::View->new; diff --git a/t/50fork.t b/t/50fork.t index af61dca..a9fbdec 100644 --- a/t/50fork.t +++ b/t/50fork.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_pg'; + use strict; use warnings; use Test::More; @@ -5,18 +7,9 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -use DBIx::Class::Optional::Dependencies (); my $main_pid = $$; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); - -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; - -plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' - . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); - # README: If you set the env var to a number greater than 10, # we will use that many children my $num_children = $ENV{DBICTEST_FORK_STRESS} || 1; @@ -24,6 +17,7 @@ if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; } +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1 }); my $parent_rs; diff --git a/t/51threads.t b/t/51threads.t index 382458d..b16fe2c 100644 --- a/t/51threads.t +++ b/t/51threads.t @@ -12,6 +12,8 @@ BEGIN { } use threads; +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_pg'; + use strict; use warnings; @@ -21,17 +23,9 @@ use Test::Exception; plan skip_all => 'DBIC does not actively support threads before perl 5.8.5' if $] < '5.008005'; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); - -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' - . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); - # README: If you set the env var to a number greater than 10, # we will use that many children my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1; @@ -39,7 +33,7 @@ if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; } -use_ok('DBICTest::Schema'); +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 }); diff --git a/t/51threadtxn.t b/t/51threadtxn.t index a0e07bd..368c9e1 100644 --- a/t/51threadtxn.t +++ b/t/51threadtxn.t @@ -15,6 +15,8 @@ BEGIN { } use threads; +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_pg'; + use strict; use warnings; @@ -23,24 +25,16 @@ use Test::More; plan skip_all => 'DBIC does not actively support threads before perl 5.8.5' if $] < '5.008005'; -use DBIx::Class::Optional::Dependencies (); use Scalar::Util 'weaken'; use lib qw(t/lib); use DBICTest; -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' - . ' (note: creates and drops a table named artist!)' unless ($dsn && $user); - -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); - my $num_children = $ENV{DBICTEST_THREAD_STRESS} || 1; if($num_children !~ /^[0-9]+$/ || $num_children < 10) { $num_children = 10; } -use_ok('DBICTest::Schema'); +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { AutoCommit => 1, RaiseError => 1, PrintError => 0 }); diff --git a/t/53lean_startup.t b/t/53lean_startup.t index cb0697a..034351e 100644 --- a/t/53lean_startup.t +++ b/t/53lean_startup.t @@ -94,6 +94,7 @@ BEGIN { constant overload + if base Devel::GlobalDestruction mro diff --git a/t/71mysql.t b/t/71mysql.t index 2f99ff5..45650a5 100644 --- a/t/71mysql.t +++ b/t/71mysql.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_mysql'; + use strict; use warnings; @@ -12,14 +14,8 @@ use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql'); - 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); - my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { quote_names => 1 }); my $dbh = $schema->storage->dbh; diff --git a/t/72pg.t b/t/72pg.t index 548423c..384eee9 100644 --- a/t/72pg.t +++ b/t/72pg.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_pg'; + use strict; use warnings; @@ -11,22 +13,9 @@ use DBICTest; use SQL::Abstract 'is_literal_value'; use DBIx::Class::_Util 'is_exception'; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_pg') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_pg'); - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; -plan skip_all => <<'EOM' unless $dsn && $user; -Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test -( NOTE: This test drops and creates tables called 'artist', 'cd', -'timestamp_primary_key_test', 'track', 'casecheck', 'array_test' and -'sequence_test' as well as following sequences: 'pkid1_seq', 'pkid2_seq' and -'nonpkid_seq'. as well as following schemas: 'dbic_t_schema', -'dbic_t_schema_2', 'dbic_t_schema_3', 'dbic_t_schema_4', and 'dbic_t_schema_5') -EOM - ### load any test classes that are defined further down in the file via BEGIN blocks - our @test_classes; #< array that will be pushed into by test classes defined in this file DBICTest::Schema->load_classes( map {s/.+:://;$_} @test_classes ) if @test_classes; diff --git a/t/72pg_bytea.t b/t/72pg_bytea.t index ac5b9c4..bf577a9 100644 --- a/t/72pg_bytea.t +++ b/t/72pg_bytea.t @@ -1,20 +1,15 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_pg'; + use strict; use warnings; use Test::More; -use DBIx::Class::Optional::Dependencies (); use Try::Tiny; use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_pg') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_pg'); - my ($dsn, $dbuser, $dbpass) = @ENV{map { "DBICTEST_PG_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_PG_DSN}, _USER and _PASS to run this test' - unless ($dsn && $dbuser); - my $schema = DBICTest::Schema->connect($dsn, $dbuser, $dbpass, { AutoCommit => 1 }); if ($schema->storage->_server_info->{normalized_dbms_version} >= 9.0) { diff --git a/t/73oracle.t b/t/73oracle.t index bdcc732..c6211e2 100644 --- a/t/73oracle.t +++ b/t/73oracle.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_oracle'; + use strict; use warnings; @@ -5,26 +7,19 @@ use Test::Exception; use Test::More; use Sub::Name; use Try::Tiny; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; +$ENV{NLS_SORT} = "BINARY"; +$ENV{NLS_COMP} = "BINARY"; +$ENV{NLS_LANG} = "AMERICAN"; + my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; # optional: my ($dsn2, $user2, $pass2) = @ENV{map { "DBICTEST_ORA_EXTRAUSER_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test.' - unless ($dsn && $user && $pass); - -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'); - -$ENV{NLS_SORT} = "BINARY"; -$ENV{NLS_COMP} = "BINARY"; -$ENV{NLS_LANG} = "AMERICAN"; - { package # hide from PAUSE DBICTest::Schema::ArtistFQN; diff --git a/t/73oracle_blob.t b/t/73oracle_blob.t index 2a78d36..fb330c6 100644 --- a/t/73oracle_blob.t +++ b/t/73oracle_blob.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_oracle'; + use strict; use warnings; @@ -5,23 +7,16 @@ use Test::Exception; use Test::More; use Sub::Name; use Try::Tiny; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; - -plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test.' - unless ($dsn && $user && $pass); - -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'); - $ENV{NLS_SORT} = "BINARY"; $ENV{NLS_COMP} = "BINARY"; $ENV{NLS_LANG} = "AMERICAN"; +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; + my $v = do { my $si = DBICTest::Schema->connect($dsn, $user, $pass)->storage->_server_info; $si->{normalized_dbms_version} diff --git a/t/73oracle_hq.t b/t/73oracle_hq.t index 6d27a05..57bdc2b 100644 --- a/t/73oracle_hq.t +++ b/t/73oracle_hq.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_oracle'; + use strict; use warnings; @@ -8,22 +10,8 @@ use Test::More; # dealing with HQs. So just punt on the entire shuffle thing. BEGIN { $ENV{DBIC_SHUFFLE_UNORDERED_RESULTSETS} = 0 } - -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); -$ENV{NLS_SORT} = "BINARY"; -$ENV{NLS_COMP} = "BINARY"; -$ENV{NLS_LANG} = "AMERICAN"; - -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; - -plan skip_all => 'Set $ENV{DBICTEST_ORA_DSN}, _USER and _PASS to run this test.' - unless ($dsn && $user && $pass); - -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('rdbms_oracle') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('rdbms_oracle'); - use DBICTest::Schema::Artist; BEGIN { DBICTest::Schema::Artist->add_column('parentid'); @@ -42,6 +30,11 @@ BEGIN { use DBICTest; use DBICTest::Schema; +$ENV{NLS_SORT} = "BINARY"; +$ENV{NLS_COMP} = "BINARY"; +$ENV{NLS_LANG} = "AMERICAN"; + +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); note "Oracle Version: " . $schema->storage->_server_info->{dbms_version}; diff --git a/t/745db2.t b/t/745db2.t index 9123330..17a6343 100644 --- a/t/745db2.t +++ b/t/745db2.t @@ -1,23 +1,15 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_db2'; + use strict; use warnings; use Test::More; use Test::Exception; use Try::Tiny; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_db2') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_db2'); - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_${_}" } qw/DSN USER PASS/}; - -#warn "$dsn $user $pass"; - -plan skip_all => 'Set $ENV{DBICTEST_DB2_DSN}, _USER and _PASS to run this test' - unless ($dsn && $user); - my $schema = DBICTest::Schema->connect($dsn, $user, $pass); my $name_sep = $schema->storage->_dbh_get_info('SQL_QUALIFIER_NAME_SEPARATOR'); diff --git a/t/746db2_400.t b/t/746db2_400.t index 3a5d902..b6c4350 100644 --- a/t/746db2_400.t +++ b/t/746db2_400.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_db2_400'; + use strict; use warnings; @@ -6,18 +8,10 @@ use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_db2_400') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_db2_400'); - -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/}; - -#warn "$dsn $user $pass"; - # Probably best to pass the DBQ option in the DSN to specify a specific # libray. Something like: # DBICTEST_DB2_400_DSN='dbi:ODBC:dsn=MyAS400;DBQ=MYLIB' -plan skip_all => 'Set $ENV{DBICTEST_DB2_400_DSN}, _USER and _PASS to run this test' - unless ($dsn && $user); +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_DB2_400_${_}" } qw/DSN USER PASS/}; plan tests => 6; diff --git a/t/746mssql.t b/t/746mssql.t index e4a9de0..23778a4 100644 --- a/t/746mssql.t +++ b/t/746mssql.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_mssql_odbc'; + use strict; use warnings; @@ -5,18 +7,11 @@ use Test::More; use Test::Exception; use Try::Tiny; -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; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ODBC_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ODBC_DSN}, _USER and _PASS to run this test' - unless ($dsn && $user); - { my $srv_ver = DBICTest::Schema->connect($dsn, $user, $pass)->storage->_server_info->{dbms_version}; ok ($srv_ver, 'Got a test server version on fresh schema: ' . ($srv_ver||'???') ); diff --git a/t/746sybase.t b/t/746sybase.t index af1f7a3..d4588c5 100644 --- a/t/746sybase.t +++ b/t/746sybase.t @@ -1,34 +1,26 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_ase'; + use strict; use warnings; no warnings 'uninitialized'; use Test::More; use Test::Exception; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}; -if (not ($dsn && $user)) { - plan skip_all => join ' ', - 'Set $ENV{DBICTEST_SYBASE_DSN}, _USER and _PASS to run this test.', - 'Warning: This test drops and creates the tables:', - "'artist', 'money_test' and 'bindtype_test'", - ; -}; - -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', ); -eval "require DBIx::Class::Storage::$_;" for @storage_types; +eval "require DBIx::Class::Storage::$_;" or die $@ + for @storage_types; my $schema; my $storage_idx = -1; +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}; + sub get_schema { DBICTest::Schema->connect($dsn, $user, $pass, { on_connect_call => [ diff --git a/t/747mssql_ado.t b/t/747mssql_ado.t index 3fd7af6..9c1d084 100644 --- a/t/747mssql_ado.t +++ b/t/747mssql_ado.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_mssql_ado'; + use strict; use warnings; @@ -8,17 +10,10 @@ use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mssql_ado') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mssql_ado'); - # Example DSN (from frew): # dbi:ADO:PROVIDER=sqlncli10;SERVER=tcp:172.24.2.10;MARS Connection=True;Initial Catalog=CIS;UID=cis_web;PWD=...;DataTypeCompatibility=80; - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_ADO_${_}" } qw/DSN USER PASS/}; -plan skip_all => 'Set $ENV{DBICTEST_MSSQL_ADO_DSN}, _USER and _PASS to run this test' - unless ($dsn && $user); - DBICTest::Schema->load_classes(qw/VaryingMAX ArtistGUID/); my %binstr = ( 'small' => join('', map { chr($_) } ( 1 .. 127 )) ); diff --git a/t/748informix.t b/t/748informix.t index 42bdac8..08fc4b5 100644 --- a/t/748informix.t +++ b/t/748informix.t @@ -1,22 +1,15 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_informix'; + use strict; use warnings; use Test::More; use Test::Exception; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_informix') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_informix'); - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_INFORMIX_${_}" } qw/DSN USER PASS/}; -#warn "$dsn $user $pass"; - -plan skip_all => 'Set $ENV{DBICTEST_INFORMIX_DSN}, _USER and _PASS to run this test' - unless $dsn; - my $schema = DBICTest::Schema->connect($dsn, $user, $pass, { auto_savepoint => 1 }); diff --git a/t/74mssql.t b/t/74mssql.t index 263fecb..4f72cc4 100644 --- a/t/74mssql.t +++ b/t/74mssql.t @@ -1,22 +1,15 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_mssql_sybase'; + use strict; use warnings; use Test::More; use Test::Exception; use Scalar::Util 'weaken'; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MSSQL_${_}" } qw/DSN USER PASS/}; - -plan skip_all => 'Set $ENV{DBICTEST_MSSQL_DSN}, _USER and _PASS to run this test' - unless ($dsn); - - -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mssql_sybase') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mssql_sybase'); - { my $srv_ver = DBICTest::Schema->connect($dsn, $user, $pass)->storage->_server_info->{dbms_version}; ok ($srv_ver, 'Got a test server version on fresh schema: ' . ($srv_ver||'???') ); diff --git a/t/86sqlt.t b/t/86sqlt.t index eccc5e2..a6b17ec 100644 --- a/t/86sqlt.t +++ b/t/86sqlt.t @@ -1,19 +1,14 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'deploy'; + use strict; use warnings; use Test::More; use Test::Warn; -use lib qw(t/lib); -use DBICTest; - use Scalar::Util 'blessed'; -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 lib qw(t/lib); +use DBICTest; my $custom_deployment_statements_called = 0; @@ -23,7 +18,6 @@ sub DBICTest::Schema::deployment_statements { return $self->next::method(@_); } - # Check deployment statements ctx sensitivity { my $schema = DBICTest->init_schema (no_deploy => 1, quote_names => 1); diff --git a/t/94versioning.t b/t/94versioning.t index a154d8f..9dcdcf1 100644 --- a/t/94versioning.t +++ b/t/94versioning.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw(deploy test_rdbms_mysql); + use strict; use warnings; @@ -13,23 +15,7 @@ use lib qw(t/lib); use DBICTest; use DBIx::Class::_Util 'sigwarn_silencer'; -my ($dsn, $user, $pass); - -BEGIN { - ($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); - - 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'); - - plan skip_all => - 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_mysql') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_mysql'); -} +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_MYSQL_${_}" } qw/DSN USER PASS/}; # this is just to grab a lock { diff --git a/t/96_is_deteministic_value.t b/t/96_is_deteministic_value.t index d71886b..330d294 100644 --- a/t/96_is_deteministic_value.t +++ b/t/96_is_deteministic_value.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt'; + use strict; use warnings; @@ -7,12 +9,6 @@ use Test::Exception; use lib qw(t/lib); use DBICTest; -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'); -} - my $schema = DBICTest->init_schema(); my $artist_rs = $schema->resultset('Artist'); my $cd_rs = $schema->resultset('CD'); diff --git a/t/99dbic_sqlt_parser.t b/t/99dbic_sqlt_parser.t index 0b36850..85bf5ab 100644 --- a/t/99dbic_sqlt_parser.t +++ b/t/99dbic_sqlt_parser.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'deploy'; + use strict; use warnings; @@ -10,13 +12,6 @@ use lib qw(t/lib); use DBICTest; use DBIx::Class::_Util 'sigwarn_silencer'; -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') -} - # Test for SQLT-related leaks { my $s = DBICTest::Schema->clone; diff --git a/t/admin/02ddl.t b/t/admin/02ddl.t index d17d677..b2414c3 100644 --- a/t/admin/02ddl.t +++ b/t/admin/02ddl.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( admin deploy ); + use strict; use warnings; @@ -11,16 +13,7 @@ use lib qw(t/lib); use DBICTest; use DBIx::Class::_Util 'sigwarn_silencer'; -BEGIN { - require DBIx::Class; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin') - unless DBIx::Class::Optional::Dependencies->req_ok_for('admin'); - - 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::Admin'; +use DBIx::Class::Admin; # lock early DBICTest->init_schema(no_deploy => 1, no_populate => 1); diff --git a/t/admin/03data.t b/t/admin/03data.t index ee35001..d73f619 100644 --- a/t/admin/03data.t +++ b/t/admin/03data.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'admin'; + use strict; use warnings; @@ -7,14 +9,7 @@ use Test::Exception; use lib 't/lib'; use DBICTest; -BEGIN { - require DBIx::Class; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for('admin') - unless DBIx::Class::Optional::Dependencies->req_ok_for('admin'); -} - -use_ok 'DBIx::Class::Admin'; - +use DBIx::Class::Admin; { # test data maniplulation functions diff --git a/t/admin/10script.t b/t/admin/10script.t index 9414b84..e65ad7d 100644 --- a/t/admin/10script.t +++ b/t/admin/10script.t @@ -1,27 +1,22 @@ -# vim: filetype=perl +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_admin_script'; + use strict; use warnings; +BEGIN { + # just in case the user env has stuff in it + delete $ENV{JSON_ANY_ORDER}; +} + use Test::More; use Config; use File::Spec; use lib qw(t/lib); use DBICTest; -BEGIN { - require DBIx::Class; - plan skip_all => 'Test needs ' . - DBIx::Class::Optional::Dependencies->req_missing_for('test_admin_script') - unless DBIx::Class::Optional::Dependencies->req_ok_for('test_admin_script'); - - # just in case the user env has stuff in it - delete $ENV{JSON_ANY_ORDER}; -} - $ENV{PATH} = ''; $ENV{PERL5LIB} = join ($Config{path_sep}, @INC); -require JSON::Any; my @json_backends = qw(DWIW PP JSON CPANEL XS); # test the script is setting @INC properly diff --git a/t/cdbi/70_implicit_inflate.t b/t/cdbi/70_implicit_inflate.t index df7cb5e..145a467 100644 --- a/t/cdbi/70_implicit_inflate.t +++ b/t/cdbi/70_implicit_inflate.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_sqlite'; + use strict; use warnings; @@ -8,12 +10,6 @@ use warnings; # of the "" operator. use Test::More; -use DBIx::Class::Optional::Dependencies; - -BEGIN { - 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'); -} use lib 't/cdbi/testlib'; use ImplicitInflate; diff --git a/t/inflate/core.t b/t/inflate/core.t index aadc4af..c33054d 100644 --- a/t/inflate/core.t +++ b/t/inflate/core.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt'; + use strict; use warnings; @@ -8,9 +10,6 @@ use DBICTest; my $schema = DBICTest->init_schema(); -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 ) }, deflate => sub { shift->year } } diff --git a/t/inflate/datetime.t b/t/inflate/datetime.t index f0c6102..e2c29af 100644 --- a/t/inflate/datetime.t +++ b/t/inflate/datetime.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_sqlite'; + use strict; use warnings; @@ -12,9 +14,6 @@ delete $ENV{DBIC_DT_SEARCH_OK}; my $schema = DBICTest->init_schema(); -plan skip_all => 'DT inflation tests need ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt_sqlite') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt_sqlite'); - # inflation test my $event = $schema->resultset("Event")->find(1); diff --git a/t/inflate/datetime_determine_parser.t b/t/inflate/datetime_determine_parser.t index 802c30e..1e7759f 100644 --- a/t/inflate/datetime_determine_parser.t +++ b/t/inflate/datetime_determine_parser.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_sqlite'; + use strict; use warnings; @@ -5,9 +7,6 @@ use Test::More; use lib qw(t/lib); use DBICTest; -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 ); diff --git a/t/inflate/datetime_firebird.t b/t/inflate/datetime_firebird.t index c958d6b..207df9f 100644 --- a/t/inflate/datetime_firebird.t +++ b/t/inflate/datetime_firebird.t @@ -1,8 +1,9 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt'; + use strict; use warnings; use Test::More; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use Scope::Guard (); @@ -21,9 +22,6 @@ plan skip_all => join (' ', "WARNING: This test drops and creates a table called 'event'", ) unless grep { $ENV{"${_}_DSN"} } keys %$env2optdep; -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; for my $prefix (keys %$env2optdep) { SKIP: { diff --git a/t/inflate/datetime_informix.t b/t/inflate/datetime_informix.t index 8bbd524..8335fc4 100644 --- a/t/inflate/datetime_informix.t +++ b/t/inflate/datetime_informix.t @@ -1,27 +1,14 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw( test_dt test_rdbms_informix ); + use strict; use warnings; use Test::More; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use Scope::Guard (); -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') -. ' and ' . -DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_informix') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') - && DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_informix'); - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_INFORMIX_${_}" } qw/DSN USER PASS/}; - -if (not $dsn) { - plan skip_all => <<'EOF'; -Set $ENV{DBICTEST_INFORMIX_DSN} _USER and _PASS to run this test'. -Warning: This test drops and creates a table called 'event'"; -EOF -} - my $schema; { diff --git a/t/inflate/datetime_mysql.t b/t/inflate/datetime_mysql.t index 44699ab..8ca6d3a 100644 --- a/t/inflate/datetime_mysql.t +++ b/t/inflate/datetime_mysql.t @@ -1,18 +1,16 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_mysql'; + use strict; use warnings; use Test::More; use Test::Exception; use Test::Warn; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; use DBICTest::Schema; use DBIx::Class::_Util 'sigwarn_silencer'; -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'); - { DBICTest::Schema->load_classes('EventTZ'); local $SIG{__WARN__} = sigwarn_silencer( qr/extra \=\> .+? has been deprecated/ ); diff --git a/t/inflate/datetime_oracle.t b/t/inflate/datetime_oracle.t index 98e4b53..bf59df3 100644 --- a/t/inflate/datetime_oracle.t +++ b/t/inflate/datetime_oracle.t @@ -1,22 +1,13 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_rdbms_oracle'; + use strict; use warnings; use Test::More; use Test::Exception; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -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'); - -my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; - -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 \'event\''; -} - # DateTime::Format::Oracle needs this set $ENV{NLS_DATE_FORMAT} = 'DD-MON-YY'; $ENV{NLS_TIMESTAMP_FORMAT} = 'YYYY-MM-DD HH24:MI:SSXFF'; @@ -24,6 +15,7 @@ $ENV{NLS_LANG} = 'AMERICAN_AMERICA.WE8ISO8859P1'; $ENV{NLS_SORT} = "BINARY"; $ENV{NLS_COMP} = "BINARY"; +my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_ORA_${_}" } qw/DSN USER PASS/}; my $schema = DBICTest::Schema->connect($dsn, $user, $pass); # older oracles do not support a TIMESTAMP datatype diff --git a/t/inflate/datetime_pg.t b/t/inflate/datetime_pg.t index c02e9f8..4e51e28 100644 --- a/t/inflate/datetime_pg.t +++ b/t/inflate/datetime_pg.t @@ -1,15 +1,13 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_dt_pg'; + use strict; use warnings; use Test::More; use Test::Warn; -use DBIx::Class::Optional::Dependencies (); 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'); - DBICTest::Schema->load_classes('EventTZPg'); my $schema = DBICTest->init_schema(); diff --git a/t/inflate/datetime_sybase.t b/t/inflate/datetime_sybase.t index 597f6a3..e25ddfa 100644 --- a/t/inflate/datetime_sybase.t +++ b/t/inflate/datetime_sybase.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => qw(test_dt test_rdbms_ase); + use strict; use warnings; @@ -5,25 +7,11 @@ use Test::More; use Test::Exception; use Scope::Guard (); use Try::Tiny; -use DBIx::Class::Optional::Dependencies (); use lib qw(t/lib); use DBICTest; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_dt') -. ' and ' . -DBIx::Class::Optional::Dependencies->req_missing_for ('test_rdbms_ase') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_dt') - && DBIx::Class::Optional::Dependencies->req_ok_for ('test_rdbms_ase'); - my ($dsn, $user, $pass) = @ENV{map { "DBICTEST_SYBASE_${_}" } qw/DSN USER PASS/}; -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' and " . - "'event_small_dt'"; -} - DBICTest::Schema->load_classes('EventSmallDT'); my @storage_types = ( diff --git a/t/sqlmaker/hierarchical/oracle.t b/t/sqlmaker/hierarchical/oracle.t index 33cfeee..3495e85 100644 --- a/t/sqlmaker/hierarchical/oracle.t +++ b/t/sqlmaker/hierarchical/oracle.t @@ -1,13 +1,11 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'id_shortener'; + use strict; use warnings; use Test::More; -use lib qw(t/lib); - -use DBIx::Class::Optional::Dependencies; -plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('id_shortener'); +use lib qw(t/lib); use DBICTest::Schema::Artist; BEGIN { DBICTest::Schema::Artist->add_column('parentid'); diff --git a/t/sqlmaker/oracle.t b/t/sqlmaker/oracle.t index b474600..cd3e629 100644 --- a/t/sqlmaker/oracle.t +++ b/t/sqlmaker/oracle.t @@ -1,13 +1,9 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'id_shortener'; + use strict; use warnings; -use Test::More; - -BEGIN { - require DBIx::Class::Optional::Dependencies; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('id_shortener'); -} +use Test::More; use Test::Exception; use Data::Dumper::Concise; use lib qw(t/lib); diff --git a/t/sqlmaker/oraclejoin.t b/t/sqlmaker/oraclejoin.t index e8e7444..11298b0 100644 --- a/t/sqlmaker/oraclejoin.t +++ b/t/sqlmaker/oraclejoin.t @@ -1,14 +1,10 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'id_shortener'; + use strict; use warnings; use Test::More; -BEGIN { - require DBIx::Class::Optional::Dependencies; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('id_shortener') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('id_shortener'); -} - use lib qw(t/lib); use DBICTest ':DiffSQL'; use DBIx::Class::SQLMaker::OracleJoins; diff --git a/t/storage/dbic_pretty.t b/t/storage/dbic_pretty.t index 6a698ef..b29d1d6 100644 --- a/t/storage/dbic_pretty.t +++ b/t/storage/dbic_pretty.t @@ -1,15 +1,12 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_prettydebug'; + use strict; use warnings; + use lib qw(t/lib); use DBICTest; use Test::More; -BEGIN { - require DBIx::Class; - plan skip_all => 'Test needs ' . DBIx::Class::Optional::Dependencies->req_missing_for ('test_prettydebug') - unless DBIx::Class::Optional::Dependencies->req_ok_for ('test_prettydebug'); -} - BEGIN { delete @ENV{qw(DBIC_TRACE_PROFILE)} } { diff --git a/t/storage/deploy.t b/t/storage/deploy.t index 61610ba..3a1f66f 100644 --- a/t/storage/deploy.t +++ b/t/storage/deploy.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'deploy'; + use strict; use warnings; @@ -8,13 +10,6 @@ use Path::Class qw/dir/; use lib qw(t/lib); use DBICTest; -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') -} - local $ENV{DBI_DSN}; # this is how maint/gen_schema did it (connect() to force a storage diff --git a/t/storage/replicated.t b/t/storage/replicated.t index b735e0f..82c809d 100644 --- a/t/storage/replicated.t +++ b/t/storage/replicated.t @@ -1,22 +1,19 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_replicated'; + use strict; use warnings; use Test::More; - +use DBIx::Class::_Util 'modver_gt_or_eq_and_lt'; use lib qw(t/lib); use DBICTest; 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'); - - if (DBICTest::RunMode->is_smoker) { - my $mver = Moose->VERSION; - plan skip_all => "A trial version $mver of Moose detected known to break replication - skipping test known to fail" - if ($mver >= 1.99 and $mver <= 1.9902); - } - + plan skip_all => "A trial version of Moose detected known to break replication - skipping test known to fail" if ( + DBICTest::RunMode->is_smoker + and + modver_gt_or_eq_and_lt( 'Moose', '1.99', '1.9903' ) + ) } use Test::Moose; diff --git a/xt/optional_deps.t b/xt/optional_deps.t index c57c6bd..47b6c45 100644 --- a/xt/optional_deps.t +++ b/xt/optional_deps.t @@ -1,31 +1,30 @@ -use strict; -use warnings; -no warnings qw/once/; - my ($inc_before, $inc_after); BEGIN { - require Carp; # Carp is not used in the test, but in OptDeps, load for proper %INC comparison - $inc_before = [ keys %INC ]; require DBIx::Class::Optional::Dependencies; $inc_after = [ keys %INC ]; } +use strict; +use warnings; +no warnings qw/once/; + use Test::More; use Test::Exception; # load before we break require() use Scalar::Util(); use MRO::Compat(); +use Carp 'confess'; ok ( (! grep { $_ =~ m|DBIx/Class| } @$inc_before ), 'Nothing DBIC related was loaded before inc-test') unless $ENV{PERL5OPT}; # a defined PERL5OPT may inject extra deps crashing this test is_deeply ( [ sort @$inc_after], - [ sort (@$inc_before, 'DBIx/Class/Optional/Dependencies.pm') ], + [ sort (@$inc_before, qw( DBIx/Class/Optional/Dependencies.pm if.pm )) ], 'Nothing loaded other than DBIx::Class::OptDeps', -); +) unless $ENV{RELEASE_TESTING}; # check the project-local groups for sanity @@ -43,7 +42,7 @@ is_deeply ( { # make module loading impossible, regardless of actual libpath contents - local @INC = (sub { Carp::confess('Optional Dep Test') } ); + local @INC = (sub { confess('Optional Dep Test') } ); # basic test using the deploy target for ('deploy', ['deploy']) { diff --git a/xt/pod.t b/xt/pod.t index 0ed796b..773e5ac 100644 --- a/xt/pod.t +++ b/xt/pod.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_pod'; + use warnings; use strict; @@ -5,14 +7,6 @@ use Test::More; use lib qw(t/lib); use DBICTest; -require DBIx::Class; -unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_pod') ) { - my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_pod'); - $ENV{RELEASE_TESTING} - ? die ("Failed to load release-testing module requirements: $missing") - : plan skip_all => "Test needs: $missing" -} - # this has already been required but leave it here for CPANTS static analysis require Test::Pod; diff --git a/xt/podcoverage.t b/xt/podcoverage.t index a16a365..88bcb81 100644 --- a/xt/podcoverage.t +++ b/xt/podcoverage.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_podcoverage'; + use warnings; use strict; @@ -7,14 +9,6 @@ use lib qw(t/lib maint/.Generated_Pod/lib); use DBICTest; use namespace::clean; -require DBIx::Class; -unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_podcoverage') ) { - my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_podcoverage'); - $ENV{RELEASE_TESTING} - ? die ("Failed to load release-testing module requirements: $missing") - : plan skip_all => "Test needs: $missing" -} - # this has already been required but leave it here for CPANTS static analysis require Test::Pod::Coverage; @@ -40,6 +34,11 @@ my $exceptions = { mk_classaccessor /] }, + 'DBIx::Class::Optional::Dependencies' => { + ignore => [qw/ + croak + /] + }, 'DBIx::Class::Carp' => { ignore => [qw/ unimport diff --git a/xt/strictures.t b/xt/strictures.t index adfd9a7..7f67779 100644 --- a/xt/strictures.t +++ b/xt/strictures.t @@ -1,19 +1,13 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_strictures'; + use warnings; use strict; use Test::More; +use File::Find; use lib 't/lib'; use DBICTest; -unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_strictures') ) { - my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_strictures'); - $ENV{RELEASE_TESTING} - ? die ("Failed to load release-testing module requirements: $missing") - : plan skip_all => "Test needs: $missing" -} - -use File::Find; - # The rationale is - if we can load all our optdeps # that are related to lib/ - then we should be able to run # perl -c checks (via syntax_ok), and all should just work @@ -33,6 +27,8 @@ find({ maint/Makefile.PL.inc/.+ # all the maint inc snippets are auto-strictured | t/lib/DBICTest/Util/OverrideRequire.pm # no stictures by design (load order sensitive) + | + lib/DBIx/Class/Optional/Dependencies.pm # no stictures by design (load spee sensitive) )$}x; my $f = $_; diff --git a/xt/whitespace.t b/xt/whitespace.t index 62405bb..3576da6 100644 --- a/xt/whitespace.t +++ b/xt/whitespace.t @@ -1,3 +1,5 @@ +use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_whitespace'; + use warnings; use strict; @@ -6,14 +8,6 @@ use File::Glob 'bsd_glob'; use lib 't/lib'; use DBICTest ':GlobalLock'; -require DBIx::Class; -unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_whitespace') ) { - my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_whitespace'); - $ENV{RELEASE_TESTING} - ? die ("Failed to load release-testing module requirements: $missing") - : plan skip_all => "Test needs: $missing" -} - # FIXME - temporary workaround for RT#82032, RT#82033 # also add all scripts (no extension) and some extra extensions # we want to check