Fix brainfart from cb551b07 - 'if' is still a module, don't need it
[dbsrgits/DBIx-Class.git] / xt / extra / internals / optional_deps.t
index bf342f9..c33fd23 100644 (file)
@@ -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']) {
@@ -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