Add import-time-skip support to OptDeps, switch most tests over to that
[dbsrgits/DBIx-Class.git] / xt / strictures.t
index 0ece5c9..7f67779 100644 (file)
@@ -1,19 +1,22 @@
+use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_strictures';
+
 use warnings;
 use strict;
 
 use Test::More;
-use lib 't/lib';
-use DBICTest ':GlobalLock';
-
-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;
+use lib 't/lib';
+use DBICTest;
+
+# 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
+my $missing_groupdeps_present = grep
+  { DBIx::Class::Optional::Dependencies->req_ok_for($_) }
+  grep
+    { $_ !~ /^ (?: test | rdbms | dist ) _ /x }
+    keys %{DBIx::Class::Optional::Dependencies->req_group_list}
+;
 
 find({
   wanted => sub {
@@ -23,19 +26,9 @@ find({
     return if m{^(?:
       maint/Makefile.PL.inc/.+                        # all the maint inc snippets are auto-strictured
         |
-      lib/DBIx/Class/Admin/Types.pm                   # MooseX::Types undetected
-        |
-      lib/DBIx/Class/Storage/DBI/Replicated/Types.pm  # MooseX::Types undetected
-        |
-      lib/DBIx/Class/Storage/BlockRunner.pm           # Moo undetected
-        |
       t/lib/DBICTest/Util/OverrideRequire.pm          # no stictures by design (load order sensitive)
         |
-      lib/DBIx/Class/Storage/DBI/Replicated/Replicant.pm  # Moose::Role no longer detected (RT#83433)
-        |
-      lib/DBIx/Class/Storage/DBI/Replicated/WithDSN.pm    # Moose::Role no longer detected (RT#83433)
-        |
-      lib/DBIx/Class/Storage/DBI/Replicated/Balancer.pm   # Moose::Role no longer detected (RT#83433)
+      lib/DBIx/Class/Optional/Dependencies.pm         # no stictures by design (load spee sensitive)
     )$}x;
 
     my $f = $_;
@@ -43,7 +36,8 @@ find({
     Test::Strict::strict_ok($f);
     Test::Strict::warnings_ok($f);
 
-    #Test::Strict::syntax_ok($f) if $f =~ /^ (?: lib  )/x;
+    Test::Strict::syntax_ok($f)
+      if ! $missing_groupdeps_present and $f =~ /^ (?: lib  )/x;
   },
   no_chdir => 1,
 }, (qw(lib t examples maint)) );