adfd9a71f0d60b546c041358a3b04f9c79796865
[dbsrgits/DBIx-Class.git] / xt / strictures.t
1 use warnings;
2 use strict;
3
4 use Test::More;
5 use lib 't/lib';
6 use DBICTest;
7
8 unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_strictures') ) {
9   my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_strictures');
10   $ENV{RELEASE_TESTING}
11     ? die ("Failed to load release-testing module requirements: $missing")
12     : plan skip_all => "Test needs: $missing"
13 }
14
15 use File::Find;
16
17 # The rationale is - if we can load all our optdeps
18 # that are related to lib/ - then we should be able to run
19 # perl -c checks (via syntax_ok), and all should just work
20 my $missing_groupdeps_present = grep
21   { DBIx::Class::Optional::Dependencies->req_ok_for($_) }
22   grep
23     { $_ !~ /^ (?: test | rdbms | dist ) _ /x }
24     keys %{DBIx::Class::Optional::Dependencies->req_group_list}
25 ;
26
27 find({
28   wanted => sub {
29     -f $_ or return;
30     m/\.(?: pm | pl | t )$ /ix or return;
31
32     return if m{^(?:
33       maint/Makefile.PL.inc/.+                        # all the maint inc snippets are auto-strictured
34         |
35       t/lib/DBICTest/Util/OverrideRequire.pm          # no stictures by design (load order sensitive)
36     )$}x;
37
38     my $f = $_;
39
40     Test::Strict::strict_ok($f);
41     Test::Strict::warnings_ok($f);
42
43     Test::Strict::syntax_ok($f)
44       if ! $missing_groupdeps_present and $f =~ /^ (?: lib  )/x;
45   },
46   no_chdir => 1,
47 }, (qw(lib t examples maint)) );
48
49 done_testing;