Ensure the testddl is regenerated at Makefile and distdir times
[dbsrgits/DBIx-Class.git] / xt / whitespace.t
1 use warnings;
2 use strict;
3
4 use Test::More;
5 use File::Glob 'bsd_glob';
6 use lib 't/lib';
7 use DBICTest;
8
9 require DBIx::Class;
10 unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_whitespace') ) {
11   my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_whitespace');
12   $ENV{RELEASE_TESTING}
13     ? die ("Failed to load release-testing module requirements: $missing")
14     : plan skip_all => "Test needs: $missing"
15 }
16
17 # FIXME - temporary workaround for RT#82032, RT#82033
18 # also add all scripts (no extension) and some extra extensions
19 # we want to check
20 {
21   no warnings 'redefine';
22   my $is_pm = sub {
23     $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|sql|json|proto)$/i || $_[0] =~ /::/;
24   };
25
26   *Test::EOL::_is_perl_module = $is_pm;
27   *Test::NoTabs::_is_perl_module = $is_pm;
28 }
29
30 my @pl_targets = qw/t xt lib script examples maint/;
31 Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets);
32 Test::NoTabs::all_perl_files_ok(@pl_targets);
33
34 # check some non-"perl files" in the root separately
35 # use .gitignore as a guide of what to skip
36 # (or do not test at all if no .gitignore is found)
37 if (open(my $gi, '<', '.gitignore')) {
38   my $skipnames;
39   while (my $ln = <$gi>) {
40     next if $ln =~ /^\s*$/;
41     chomp $ln;
42     $skipnames->{$_}++ for bsd_glob($ln);
43   }
44
45   # that we want to check anyway
46   delete $skipnames->{'META.yml'};
47
48   for my $fn (bsd_glob('*')) {
49     next if $skipnames->{$fn};
50     next unless -f $fn;
51     Test::EOL::eol_unix_ok($fn, { trailing_whitespace => 1 });
52     Test::NoTabs::notabs_ok($fn);
53   }
54 }
55
56 # FIXME - Test::NoTabs and Test::EOL declare 'no_plan' which conflicts with done_testing
57 # https://github.com/schwern/test-more/issues/14
58 #done_testing;