Fix incorrect whitespace test outside of checkouts
[dbsrgits/DBIx-Class.git] / xt / dist / postdistdir / whitespace.t
CommitLineData
c0329273 1BEGIN { do "./t/lib/ANFANG.pm" or die ( $@ || $! ) }
cb551b07 2use DBIx::Class::Optional::Dependencies -skip_all_without => 'test_whitespace';
3
0a87afc4 4use warnings;
5use strict;
6
7use Test::More;
7e1ca6dd 8use File::Glob 'bsd_glob';
c0329273 9
f892e7e4 10use DBICTest ':GlobalLock';
0a87afc4 11
ffce4b65 12# FIXME - temporary workaround for RT#82032, RT#82033
331886ef 13# also add all scripts (no extension) and some extra extensions
14# we want to check
7e1ca6dd 15{
16 no warnings 'redefine';
ffce4b65 17 my $is_pm = sub {
ffaf1f82 18 $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|bash|sql|json|proto)$/i || $_[0] =~ /::/;
ffce4b65 19 };
331886ef 20
ffce4b65 21 *Test::EOL::_is_perl_module = $is_pm;
22 *Test::NoTabs::_is_perl_module = $is_pm;
7e1ca6dd 23}
24
ffce4b65 25my @pl_targets = qw/t xt lib script examples maint/;
26Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets);
27Test::NoTabs::all_perl_files_ok(@pl_targets);
0a87afc4 28
7e1ca6dd 29# check some non-"perl files" in the root separately
fecbfe17 30# start with what we want to check no matter what .gitignore says
31my @root_files = grep { -f $_ } qw(
32 Changes
33 LICENSE
34 AUTHORS
35 README
36 MANIFEST
37 META.yml
38 META.json
39);
1fb834df 40
fecbfe17 41# if .gitignore is available - go for * and use .gitignore as a guide
42# of what to skip
7e1ca6dd 43if (open(my $gi, '<', '.gitignore')) {
44 my $skipnames;
45 while (my $ln = <$gi>) {
46 next if $ln =~ /^\s*$/;
47 chomp $ln;
48 $skipnames->{$_}++ for bsd_glob($ln);
49 }
50
fecbfe17 51 delete @{$skipnames}{@root_files};
52
53 @root_files = grep {
54 ! $skipnames->{$_}
55 and
56 -f $_
57 } bsd_glob('*');
1fb834df 58}
ffce4b65 59
1fb834df 60for my $fn (@root_files) {
61 Test::EOL::eol_unix_ok($fn, { trailing_whitespace => 1 });
62 Test::NoTabs::notabs_ok($fn) unless $fn eq 'MANIFEST'; # it is always tab infested
7e1ca6dd 63}
a8b66abc 64
ffce4b65 65# FIXME - Test::NoTabs and Test::EOL declare 'no_plan' which conflicts with done_testing
8273e845 66# https://github.com/schwern/test-more/issues/14
d146b340 67#done_testing;