Debian Codegraph @

xt/99-unix-text.t

raw
1 use Test::More;
2
3 # Check that all released module files are in
4 # UNIX text format
5
6 use File::Spec;
7 use File::Find;
8 use strict;
9
10 my @files = ('Makefile.PL', 'MANIFEST', 'MANIFEST.SKIP', glob 't/*.t');
11
12 require './Makefile.PL';
13 # Loaded from Makefile.PL
14 our %module = get_module_info();
15
16 my @files;
17 my $blib = File::Spec->catfile(qw(blib lib));
18 find(\&wanted, grep { -d } ($blib));
19
20 if( my $exe = $module{EXE_FILES}) {
21 push @files, @$exe;
22 };
23
24 plan tests => scalar @files;
25 foreach my $file (@files) {
26 unix_file_ok($file);
27 }
28
29 sub wanted {
30 push @files, $File::Find::name if /\.p(l|m|od)$/;
31 }
32
33 sub unix_file_ok {
34 my ($filename) = @_;
35 local $/;
36 open my $fh, '<', $filename
37 or die "Couldn't open '$filename' : $!\n";
38 binmode $fh;
39 my $content = <$fh>;
40
41 my $i;
42 my @lines = grep { /\x0D\x0A$/sm } map { sprintf "%s: %s\x0A", $i++, $_ } split /\x0A/, $content;
43 unless (is(scalar @lines, 0,"'$filename' contains no windows newlines")) {
44 diag $_ for @lines;
45 };
46 close $fh;
47 };