From 515e0cf114ef9fb8068034f00769b9bc0771fbed Mon Sep 17 00:00:00 2001 From: =?utf8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Fri, 20 Jul 2007 00:05:48 +0000 Subject: [PATCH] don't slurp the whole file, we only need to test line 1, this speeds things up immensely --- t/maint/bom.t | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/t/maint/bom.t b/t/maint/bom.t index 4c50c1f433..b5e6ae9864 100644 --- a/t/maint/bom.t +++ b/t/maint/bom.t @@ -14,14 +14,12 @@ use warnings; use Test::More; use File::Find; -use File::Slurp qw< slurp >; # Files for wich we want to check the BOM char ( 0xFE 0XFF ) my $ext = qr/(?:php|inc)/x ; my $bomchar = qr/\xef\xbb\xbf/ ; - my @files; find( sub{ push @files, $File::Find::name if -f && /\.$ext$/ }, '.' ); @@ -30,10 +28,11 @@ find( sub{ push @files, $File::Find::name if -f && /\.$ext$/ }, '.' ); plan tests => scalar @files ; for my $file (@files) { - my $content = slurp $file ; - if( $content =~ /$bomchar/ ) { - fail "$file got a Byte Order Mark"; + open my $fh, "<", $file or die "Couln't open $file: $!"; + my $line = <$fh>; + if( $line =~ /$bomchar/ ) { + fail "$file has a Byte Order Mark at line $."; } else { - pass "$file BOM less"; + pass "$file has no Byte Order Mark!"; } } -- 2.20.1