don't slurp the whole file, we only need to test line 1, this speeds things up immensely
authorÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 20 Jul 2007 00:05:48 +0000 (00:05 +0000)
committerÆvar Arnfjörð Bjarmason <avar@users.mediawiki.org>
Fri, 20 Jul 2007 00:05:48 +0000 (00:05 +0000)
t/maint/bom.t

index 4c50c1f..b5e6ae9 100644 (file)
@@ -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!";
        }
 }