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
# POD is generated automatically by calling _gen_pod from the
# Makefile.PL in $AUTHOR mode
-# NOTE: the rationale for 2 JSON::Any versions is that
-# we need the newer only to work around JSON::XS, which
-# itself is an optional dep
-my $min_json_any = {
- 'JSON::Any' => '1.23',
-};
-my $test_and_dist_json_any = {
- 'JSON::Any' => '1.31',
-};
-
+# *DELIBERATELY* not making a group for these - they must disappear
+# forever as optdeps in the first place
my $moose_basic = {
'Moose' => '0.98',
'MooseX::Types' => '0.21',
};
my $dbic_reqs = {
+
+ # NOTE: the rationale for 2 JSON::Any versions is that
+ # we need the newer only to work around JSON::XS, which
+ # itself is an optional dep
+ _json_any => {
+ req => {
+ 'JSON::Any' => '1.23',
+ },
+ },
+
+ _json_xs_compatible_json_any => {
+ req => {
+ 'JSON::Any' => '1.31',
+ },
+ },
+
+ # a common placeholder for engines with IC::DT support based off DT::F::S
+ # currently unused on purpose (see next commits)
+ _icdt_strptime_based => {},
+
+ _rdbms_generic_odbc => {
+ req => {
+ 'DBD::ODBC' => 0,
+ }
+ },
+
+ _rdbms_generic_ado => {
+ req => {
+ 'DBD::ADO' => 0,
+ }
+ },
+
replicated => {
req => $moose_basic,
pod => {
},
admin => {
+ include => '_json_any',
req => {
%$moose_basic,
- %$min_json_any,
'MooseX::Types::Path::Class' => '0.05',
'MooseX::Types::JSON' => '0.02',
},
req => {
'Test::Pod' => '1.42',
},
+ release_testing_mandatory => 1,
},
test_podcoverage => {
'Test::Pod::Coverage' => '1.08',
'Pod::Coverage' => '0.20',
},
+ release_testing_mandatory => 1,
},
test_whitespace => {
'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 => {
- req => $min_json_any,
+ include => '_json_any',
},
test_admin_script => {
- include => 'admin_script',
+ include => [qw( admin_script _json_xs_compatible_json_any )],
req => {
- %$test_and_dist_json_any,
'JSON' => 0,
'JSON::PP' => 0,
'Cpanel::JSON::XS' => 0,
},
},
- rdbms_generic_odbc => {
- req => {
- 'DBD::ODBC' => 0,
- }
- },
-
- rdbms_generic_ado => {
- req => {
- 'DBD::ADO' => 0,
- }
- },
-
# this is just for completeness as SQLite
# is a core dep of DBIC for testing
rdbms_sqlite => {
},
},
+ _rdbms_mssql_common => {
+ include => '_icdt_strptime_based',
+ },
+
rdbms_mssql_odbc => {
- include => 'rdbms_generic_odbc',
+ include => [qw( _rdbms_generic_odbc _rdbms_mssql_common )],
pod => {
title => 'MSSQL support via DBD::ODBC',
desc => 'Modules required to connect to MSSQL via DBD::ODBC',
},
rdbms_mssql_sybase => {
+ include => '_rdbms_mssql_common',
req => {
'DBD::Sybase' => 0,
},
},
rdbms_mssql_ado => {
- include => 'rdbms_generic_ado',
+ include => [qw( _rdbms_generic_ado _rdbms_mssql_common )],
pod => {
title => 'MSSQL support via DBD::ADO (Windows only)',
desc => 'Modules required to connect to MSSQL via DBD::ADO. This particular DBD is available on Windows only',
},
},
+ _rdbms_msaccess_common => {
+ include => '_icdt_strptime_based',
+ },
+
rdbms_msaccess_odbc => {
- include => 'rdbms_generic_odbc',
+ include => [qw( _rdbms_generic_odbc _rdbms_msaccess_common )],
pod => {
title => 'MS Access support via DBD::ODBC',
desc => 'Modules required to connect to MS Access via DBD::ODBC',
},
rdbms_msaccess_ado => {
- include => 'rdbms_generic_ado',
+ include => [qw( _rdbms_generic_ado _rdbms_msaccess_common )],
pod => {
title => 'MS Access support via DBD::ADO (Windows only)',
desc => 'Modules required to connect to MS Access via DBD::ADO. This particular DBD is available on Windows only',
},
rdbms_ase => {
+ include => '_icdt_strptime_based',
req => {
'DBD::Sybase' => 0,
},
},
},
+ _rdbms_db2_common => {
+ },
+
rdbms_db2 => {
+ include => '_rdbms_db2_common',
req => {
'DBD::DB2' => 0,
},
},
rdbms_db2_400 => {
- include => 'rdbms_generic_odbc',
+ include => [qw( _rdbms_generic_odbc _rdbms_db2_common )],
pod => {
title => 'DB2 on AS/400 support',
desc => 'Modules required to connect to DB2 on AS/400',
},
rdbms_informix => {
+ include => '_icdt_strptime_based',
req => {
'DBD::Informix' => 0,
},
},
},
+ _rdbms_sqlanywhere_common => {
+ inclide => '_icdt_strptime_based',
+ },
+
rdbms_sqlanywhere => {
+ include => '_rdbms_sqlanywhere_common',
req => {
'DBD::SQLAnywhere' => 0,
},
},
rdbms_sqlanywhere_odbc => {
- include => 'rdbms_generic_odbc',
+ include => [qw( _rdbms_generic_odbc _rdbms_sqlanywhere_common )],
pod => {
title => 'SQLAnywhere support via DBD::ODBC',
desc => 'Modules required to connect to SQLAnywhere via DBD::ODBC',
},
},
+ _rdbms_firebird_common => {
+ include => '_icdt_strptime_based',
+ },
+
rdbms_firebird => {
+ include => '_rdbms_firebird_common',
req => {
'DBD::Firebird' => 0,
},
},
rdbms_firebird_interbase => {
+ include => '_rdbms_firebird_common',
req => {
'DBD::InterBase' => 0,
},
},
rdbms_firebird_odbc => {
- include => 'rdbms_generic_odbc',
+ include => [qw( _rdbms_generic_odbc _rdbms_firebird_common )],
pod => {
title => 'Firebird support via DBD::ODBC',
desc => 'Modules required to connect to Firebird via DBD::ODBC',
},
},
+ test_rdbms_sqlite => {
+ include => 'rdbms_sqlite',
+ req => {
+ ###
+ ### IMPORTANT - do not raise this dependency
+ ### even though many bugfixes are present in newer versions, the general DBIC
+ ### rule is to bend over backwards for available DBDs (given upgrading them is
+ ### often *not* easy or even possible)
+ ###
+ 'DBD::SQLite' => '1.29',
+ },
+ },
+
test_rdbms_pg => {
include => 'rdbms_pg',
env => [
},
test_rdbms_msaccess_odbc => {
- include => [qw(rdbms_msaccess_odbc test_dt)],
+ include => 'rdbms_msaccess_odbc',
env => [
DBICTEST_MSACCESS_ODBC_DSN => 1,
DBICTEST_MSACCESS_ODBC_USER => 0,
},
test_rdbms_msaccess_ado => {
- include => [qw(rdbms_msaccess_ado test_dt)],
+ include => 'rdbms_msaccess_ado',
env => [
DBICTEST_MSACCESS_ADO_DSN => 1,
DBICTEST_MSACCESS_ADO_USER => 0,
},
dist_dir => {
+ # we need to run the dbicadmin so we can self-generate its POD
+ # also we do not want surprises in case JSON::XS is in the path
+ # so make sure we get an always-working JSON::Any
+ include => [qw( admin_script _json_xs_compatible_json_any )],
req => {
- %$test_and_dist_json_any,
'ExtUtils::MakeMaker' => '6.64',
'Pod::Inherit' => '0.91',
},
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'";
}
# standalone library - keep the stupidity to a DBIC-secific shim!
#
sub req_list_for {
- shift->_groups_to_reqs(@_)->{effective_modreqs};
+ shift->_groups_to_reqs(shift)->{effective_modreqs};
}
sub modreq_list_for {
- shift->_groups_to_reqs(@_)->{modreqs};
+ shift->_groups_to_reqs(shift)->{modreqs};
}
sub req_group_list {
+{ map
{ $_ => $_[0]->_groups_to_reqs($_) }
- keys %$dbic_reqs
+ grep { $_ !~ /^_/ } keys %$dbic_reqs
}
}
-sub req_errorlist_for { shift->modreq_errorlist_for(@_) } # deprecated
+sub req_errorlist_for { shift->modreq_errorlist_for(shift) } # deprecated
sub modreq_errorlist_for {
- my $self = shift;
- $self->_errorlist_for_modreqs( $self->_groups_to_reqs(@_)->{modreqs} );
+ my ($self, $groups) = @_;
+ $self->_errorlist_for_modreqs( $self->_groups_to_reqs($groups)->{modreqs} );
}
sub req_ok_for {
- shift->req_missing_for(@_) ? 0 : 1;
+ shift->req_missing_for(shift) ? 0 : 1;
}
sub req_missing_for {
- my $self = shift;
+ my ($self, $groups) = @_;
- my $reqs = $self->_groups_to_reqs(@_);
- my $mods_missing = $self->modreq_missing_for(@_);
+ my $reqs = $self->_groups_to_reqs($groups);
+ my $mods_missing = $self->modreq_missing_for($groups);
return '' if
! $mods_missing
my @res = $mods_missing || ();
- push @res, 'the following group(s) of environment variables: ' . join ' and ', map
+ push @res, 'the following group(s) of environment variables: ' . join ' and ', sort map
{ __envvar_group_desc($_) }
@{$reqs->{missing_envvars}}
if $reqs->{missing_envvars};
}
sub modreq_missing_for {
- my $self = shift;
+ my ($self, $groups) = @_;
- my $reqs = $self->_groups_to_reqs(@_);
+ my $reqs = $self->_groups_to_reqs($groups);
my $modreq_errors = $self->_errorlist_for_modreqs($reqs->{modreqs})
or return '';
}
sub die_unless_req_ok_for {
- if (my $err = shift->req_missing_for(@_) ) {
+ if (my $err = shift->req_missing_for(shift) ) {
die "Unable to continue due to missing requirements: $err\n";
}
}
join '/', @res;
}
-
-
### Private OO API
our %req_unavailability_cache;
for my $group ( grep { ! $processed_groups->{$_} } @$groups ) {
- $group =~ /\A [A-Za-z][0-9A-Z_a-z]* \z/x
+ $group =~ /\A [A-Z_a-z][0-9A-Z_a-z]* \z/x
or croak "Invalid requirement group name '$group': only ascii alphanumerics and _ are allowed";
croak "Requirement group '$group' is not defined" unless defined $dbic_reqs->{$group};
$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;
Even though this module is not an L<Exporter>, it recognizes several C<actions>
supplied to its C<import> 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<RELEASE_TESTING> environment variable and
+behaves like L</-die_without> for any requirement groups marked as
+C<release_testing_mandatory>.
+
=head2 -die_without
=over