summaryrefslogtreecommitdiff
path: root/t/maint/unix-newlines.t
blob: c47dd17cdbdfc0ef2afefcda7cd48ae22586a376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/env perl
use strict;
use warnings;

use Test::More;;

use File::Find;
use Socket '$CRLF';

my $ext = qr/(?: t | pm | sql | js | php | inc | xml )/x;

my @files;
find( sub { push @files, $File::Find::name if -f && /\. $ext $/x }, '.' );

plan 'no_plan';

for my $file (@files) {
    open my $fh, "<", $file or die "Can't open $file: $!";
    binmode $fh;

    my $ok = 1;
    while (<$fh>) {
        if (/$CRLF/) {
            fail "$file has \\r\\n on line $.";
            $ok = 0;
        }
    }

    pass "$file has only unix newlines" if $ok;
}