From: Peter Rabbitson Date: Sat, 3 Jan 2015 12:16:25 +0000 (+0100) Subject: More robust 'nothing loaded' test for optdeps (read under -w) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c052f3dd7e8d15c02fbe02f672c57f0c532830ea;p=dbsrgits%2FDBIx-Class-Historic.git More robust 'nothing loaded' test for optdeps (read under -w) --- diff --git a/xt/optional_deps.t b/xt/optional_deps.t index efb7edf..4507e3b 100644 --- a/xt/optional_deps.t +++ b/xt/optional_deps.t @@ -2,30 +2,26 @@ use strict; use warnings; no warnings qw/once/; -use Test::More; -use Test::Exception; -use lib qw(t/lib); -use Scalar::Util; # load before we break require() -use Carp (); # Carp is not used in the test, but we want to have it loaded for proper %INC comparison - -# a dummy test which lazy-loads more modules (so we can compare INC below) -is_deeply([], []); - -# record contents of %INC - makes sure there are no extra deps slipping into -# Opt::Dep. -my $inc_before = [ keys %INC ]; -ok ( (! grep { $_ =~ m|DBIx/Class| } @$inc_before ), 'Nothing DBIC related is yet loaded'); - +my ($inc_before, $inc_after); # DBIx::Class::Optional::Dependencies queries $ENV at compile time # to build the optional requirements BEGIN { $ENV{DBICTEST_PG_DSN} = '1'; delete $ENV{DBICTEST_ORA_DSN}; + + 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_ok 'DBIx::Class::Optional::Dependencies'; +use Test::More; +use Test::Exception; +use Scalar::Util; # load before we break require() -my $inc_after = [ keys %INC ]; +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],