Reign in (a little bit) the sprawling CRLF insanity on Win32
[dbsrgits/DBIx-Class.git] / xt / whitespace.t
CommitLineData
0a87afc4 1use warnings;
2use strict;
3
4use Test::More;
7e1ca6dd 5use File::Glob 'bsd_glob';
0a87afc4 6use lib 't/lib';
7use DBICTest;
8
d146b340 9require DBIx::Class;
ffce4b65 10unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_whitespace') ) {
11 my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_whitespace');
20884f55 12 $ENV{RELEASE_TESTING}
d146b340 13 ? die ("Failed to load release-testing module requirements: $missing")
14 : plan skip_all => "Test needs: $missing"
0a87afc4 15}
16
ffce4b65 17# FIXME - temporary workaround for RT#82032, RT#82033
331886ef 18# also add all scripts (no extension) and some extra extensions
19# we want to check
7e1ca6dd 20{
21 no warnings 'redefine';
ffce4b65 22 my $is_pm = sub {
23 $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|sql|json|proto)$/i || $_[0] =~ /::/;
24 };
331886ef 25
ffce4b65 26 *Test::EOL::_is_perl_module = $is_pm;
27 *Test::NoTabs::_is_perl_module = $is_pm;
7e1ca6dd 28}
29
ffce4b65 30my @pl_targets = qw/t xt lib script examples maint/;
31Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets);
32Test::NoTabs::all_perl_files_ok(@pl_targets);
0a87afc4 33
7e1ca6dd 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)
37if (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
ffce4b65 45 # that we want to check anyway
46 delete $skipnames->{'META.yml'};
47
7e1ca6dd 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 });
ffce4b65 52 Test::NoTabs::notabs_ok($fn);
7e1ca6dd 53 }
54}
a8b66abc 55
ffce4b65 56# FIXME - Test::NoTabs and Test::EOL declare 'no_plan' which conflicts with done_testing
8273e845 57# https://github.com/schwern/test-more/issues/14
d146b340 58#done_testing;