X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Fextra%2Finternals%2Foptional_deps.t;h=7da1cc43eb577c59dea62276a9745ae8478c44de;hb=74919a00766bc8f9bd9f6170d1977e186ce676d5;hp=bf342f91fd63e5d118e3925579cc1188175bcdb0;hpb=c26b30dee587fa008f7d956b61ae27c36ac7ec82;p=dbsrgits%2FDBIx-Class.git diff --git a/xt/extra/internals/optional_deps.t b/xt/extra/internals/optional_deps.t index bf342f9..7da1cc4 100644 --- a/xt/extra/internals/optional_deps.t +++ b/xt/extra/internals/optional_deps.t @@ -18,14 +18,20 @@ use MRO::Compat(); use Carp 'confess'; use List::Util 'shuffle'; -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, qw( DBIx/Class/Optional/Dependencies.pm if.pm )) ], - 'Nothing loaded other than DBIx::Class::OptDeps', -) unless $ENV{RELEASE_TESTING}; +SKIP: { + skip 'Lean load pattern testing unsafe with $ENV{PERL5OPT}', 1 if $ENV{PERL5OPT}; + skip 'Lean load pattern testing useless with $ENV{RELEASE_TESTING}', 1 if $ENV{RELEASE_TESTING}; + is_deeply + $inc_before, + [], + 'Nothing was loaded before inc-test' + ; + is_deeply + $inc_after, + [ 'DBIx/Class/Optional/Dependencies.pm' ], + 'Nothing was loaded other than DBIx::Class::OptDeps' + ; +} # check the project-local groups for sanity lives_ok { @@ -42,7 +48,7 @@ is_deeply ( { # make module loading impossible, regardless of actual libpath contents - local @INC = (sub { confess('Optional Dep Test') } ); + local @INC; # basic test using the deploy target for ('deploy', ['deploy']) { @@ -59,7 +65,7 @@ is_deeply ( DBIx::Class::Optional::Dependencies->modreq_missing_for ($_), qr/ \A - " SQL::Translator \~ \>\= [\d\.]+ " + SQL::Translator \~ [\d\.]+ \z /x, 'expected modreq missing string contents', @@ -69,7 +75,7 @@ is_deeply ( DBIx::Class::Optional::Dependencies->req_missing_for ($_), qr/ \A - " SQL::Translator \~ \>\= [\d\.]+ " + SQL::Translator \~ [\d\.]+ \Q (see DBIx::Class::Optional::Dependencies documentation for details)\E \z /x, @@ -78,8 +84,8 @@ is_deeply ( like ( DBIx::Class::Optional::Dependencies->modreq_errorlist_for ($_)->{'SQL::Translator'}, - qr/Optional Dep Test/, - 'custom exception found in errorlist', + qr|\QCan't locate SQL/Translator.pm|, + 'correct "unable to locate" exception found in errorlist', ); #make it so module appears loaded @@ -131,13 +137,13 @@ is_deeply ( # regular is_deeply( - DBIx::Class::Optional::Dependencies->modreq_list_for('test_rdbms_pg'), + DBIx::Class::Optional::Dependencies->modreq_list_for([shuffle qw( test_rdbms_pg binary_data )]), { 'DBD::Pg' => '2.009002' }, 'optional dependencies list for testing Postgres without envvar', ); is_deeply( - DBIx::Class::Optional::Dependencies->req_list_for('test_rdbms_pg'), + DBIx::Class::Optional::Dependencies->req_list_for([shuffle qw( test_rdbms_pg binary_data )]), undef, 'optional dependencies list for testing Postgres without envvar', ); @@ -162,37 +168,39 @@ is_deeply ( ); is( - DBIx::Class::Optional::Dependencies->req_missing_for([qw( rdbms_pg test_rdbms_pg )]), - '"DBD::Pg~>=2.009002" as well as the following group(s) of environment variables: DBICTEST_PG_DSN/..._USER/..._PASS', + DBIx::Class::Optional::Dependencies->req_missing_for([shuffle qw( rdbms_pg test_rdbms_pg binary_data )]), + 'DBD::Pg~2.009002 as well as the following group(s) of environment variables: DBICTEST_PG_DSN/..._USER/..._PASS', 'optional dependencies for testing Postgres without envvar' ); is( - DBIx::Class::Optional::Dependencies->req_missing_for([shuffle qw( test_rdbms_mysql test_rdbms_pg )]), - 'DBD::mysql "DBD::Pg~>=2.009002" as well as the following group(s) of environment variables: DBICTEST_MYSQL_DSN/..._USER/..._PASS and DBICTEST_PG_DSN/..._USER/..._PASS', + DBIx::Class::Optional::Dependencies->req_missing_for([shuffle qw( test_rdbms_mysql test_rdbms_pg binary_data)]), + 'DBD::mysql DBD::Pg~2.009002 as well as the following group(s) of environment variables: DBICTEST_MYSQL_DSN/..._USER/..._PASS and DBICTEST_PG_DSN/..._USER/..._PASS', 'optional dependencies for testing Postgres+MySQL without envvars' ); $ENV{DBICTEST_PG_DSN} = 'boo'; is_deeply ( - DBIx::Class::Optional::Dependencies->modreq_list_for([shuffle qw( rdbms_pg test_rdbms_pg )]), + DBIx::Class::Optional::Dependencies->modreq_list_for([shuffle qw( rdbms_pg test_rdbms_pg binary_data)]), { 'DBD::Pg' => '2.009002' }, 'optional module dependencies list for testing Postgres matches with envvar', ); is( - DBIx::Class::Optional::Dependencies->req_missing_for([shuffle qw( rdbms_pg test_rdbms_pg )]), - '"DBD::Pg~>=2.009002"', + DBIx::Class::Optional::Dependencies->req_missing_for([shuffle qw( rdbms_pg test_rdbms_pg binary_data )]), + 'DBD::Pg~2.009002', 'optional dependencies error text for testing Postgres matches with evvar', ); # ICDT augmentation - my $mysql_icdt = [shuffle qw( test_rdbms_mysql icdt )]; + my %expected_icdt_base = ( DateTime => '0.55', 'DateTime::TimeZone::OlsonDB' => 0 ); + + my $mysql_icdt = [shuffle qw( test_rdbms_mysql ic_dt )]; is_deeply( DBIx::Class::Optional::Dependencies->modreq_list_for($mysql_icdt), { - 'DateTime' => '0.55', + %expected_icdt_base, 'DBD::mysql' => 0, 'DateTime::Format::MySQL' => 0, }, @@ -201,31 +209,29 @@ is_deeply ( is_deeply( DBIx::Class::Optional::Dependencies->req_list_for($mysql_icdt), - { - 'DateTime' => '0.55', - }, + \%expected_icdt_base, 'optional dependencies list for testing ICDT MySQL without envvar', ); is( DBIx::Class::Optional::Dependencies->req_missing_for($mysql_icdt), - '"DateTime~>=0.55" DateTime::Format::MySQL DBD::mysql as well as the following group(s) of environment variables: DBICTEST_MYSQL_DSN/..._USER/..._PASS', + "DateTime~0.55 DateTime::Format::MySQL DateTime::TimeZone::OlsonDB DBD::mysql as well as the following group(s) of environment variables: DBICTEST_MYSQL_DSN/..._USER/..._PASS", 'missing optional dependencies for testing ICDT MySQL without envvars' ); # test multi-level include with a variable and mandatory part converging on same included dep local $ENV{DBICTEST_MSACCESS_ODBC_DSN}; local $ENV{DBICTEST_MSSQL_ODBC_DSN} = 'foo'; - my $msaccess_mssql_icdt = [ shuffle qw( test_rdbms_msaccess_odbc test_rdbms_mssql_odbc icdt ) ]; + my $msaccess_mssql_icdt = [ shuffle qw( test_rdbms_msaccess_odbc test_rdbms_mssql_odbc ic_dt ) ]; is_deeply( DBIx::Class::Optional::Dependencies->req_missing_for($msaccess_mssql_icdt), - 'Data::GUID "DateTime~>=0.55" "DateTime::Format::Strptime~>=1.2" DBD::ODBC as well as the following group(s) of environment variables: DBICTEST_MSACCESS_ODBC_DSN/..._USER/..._PASS', + 'Data::GUID DateTime~0.55 DateTime::Format::Strptime~1.2 DateTime::TimeZone::OlsonDB DBD::ODBC as well as the following group(s) of environment variables: DBICTEST_MSACCESS_ODBC_DSN/..._USER/..._PASS', 'Correct req_missing_for on multi-level converging include', ); is_deeply( DBIx::Class::Optional::Dependencies->modreq_missing_for($msaccess_mssql_icdt), - 'Data::GUID "DateTime~>=0.55" "DateTime::Format::Strptime~>=1.2" DBD::ODBC', + 'Data::GUID DateTime~0.55 DateTime::Format::Strptime~1.2 DateTime::TimeZone::OlsonDB DBD::ODBC', 'Correct modreq_missing_for on multi-level converging include', ); @@ -233,8 +239,8 @@ is_deeply ( DBIx::Class::Optional::Dependencies->req_list_for($msaccess_mssql_icdt), { 'DBD::ODBC' => 0, - 'DateTime' => '0.55', 'DateTime::Format::Strptime' => '1.2', + %expected_icdt_base, }, 'Correct req_list_for on multi-level converging include', ); @@ -244,8 +250,8 @@ is_deeply ( { 'DBD::ODBC' => 0, 'Data::GUID' => 0, - 'DateTime' => '0.55', 'DateTime::Format::Strptime' => '1.2', + %expected_icdt_base, }, 'Correct modreq_list_for on multi-level converging include', );