Commit | Line | Data |
428975b0 |
1 | use warnings; |
2 | use strict; |
3 | |
4 | use Test::More; |
5 | use File::Glob 'bsd_glob'; |
6 | use lib 't/lib'; |
7 | |
8 | eval "use Test::EOL 1.0 ()"; |
9 | plan skip_all => 'Test::EOL 1.0 required' if $@; |
10 | eval "use Test::NoTabs 0.9 ()"; |
11 | plan skip_all => 'Test::NoTabs 0.9 required' if $@; |
12 | |
13 | # FIXME - temporary workaround for RT#82032, RT#82033 |
14 | # also add all scripts (no extension) and some extra extensions |
15 | # we want to check |
16 | { |
17 | no warnings 'redefine'; |
18 | my $is_pm = sub { |
19 | $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|bash|sql|json|proto)$/i || $_[0] =~ /::/; |
20 | }; |
21 | |
22 | *Test::EOL::_is_perl_module = $is_pm; |
23 | *Test::NoTabs::_is_perl_module = $is_pm; |
24 | } |
25 | |
de1d8586 |
26 | my @pl_targets = qw/t lib examples/; |
428975b0 |
27 | Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets); |
28 | Test::NoTabs::all_perl_files_ok(@pl_targets); |
29 | |
30 | # check some non-"perl files" in the root separately |
31 | # use .gitignore as a guide of what to skip |
32 | # (or do not test at all if no .gitignore is found) |
33 | if (open(my $gi, '<', '.gitignore')) { |
34 | my $skipnames; |
35 | while (my $ln = <$gi>) { |
36 | next if $ln =~ /^\s*$/; |
37 | chomp $ln; |
38 | $skipnames->{$_}++ for bsd_glob($ln); |
39 | } |
40 | |
41 | # that we want to check anyway |
42 | delete $skipnames->{'META.yml'}; |
43 | |
44 | for my $fn (bsd_glob('*')) { |
45 | next if $skipnames->{$fn}; |
46 | next unless -f $fn; |
47 | Test::EOL::eol_unix_ok($fn, { trailing_whitespace => 1 }); |
48 | Test::NoTabs::notabs_ok($fn); |
49 | } |
50 | } |
51 | |
52 | # FIXME - Test::NoTabs and Test::EOL declare 'no_plan' which conflicts with done_testing |
53 | # https://github.com/schwern/test-more/issues/14 |
54 | #done_testing; |