After 5f3fa0ac script/ is no more
[dbsrgits/SQL-Abstract.git] / xt / 92whitespace.t
CommitLineData
428975b0 1use warnings;
2use strict;
3
4use Test::More;
5use File::Glob 'bsd_glob';
6use lib 't/lib';
7
8eval "use Test::EOL 1.0 ()";
9plan skip_all => 'Test::EOL 1.0 required' if $@;
10eval "use Test::NoTabs 0.9 ()";
11plan 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 26my @pl_targets = qw/t lib examples/;
428975b0 27Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets);
28Test::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)
33if (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;