From: Ævar Arnfjörð Bjarmason Date: Fri, 20 Jul 2007 00:05:48 +0000 (+0000) Subject: don't slurp the whole file, we only need to test line 1, this speeds things up immensely X-Git-Tag: 1.31.0-rc.0~52004 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/load.php?a=commitdiff_plain;h=515e0cf114ef9fb8068034f00769b9bc0771fbed;p=lhc%2Fweb%2Fwiklou.git don't slurp the whole file, we only need to test line 1, this speeds things up immensely --- 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!"; } }