LocalFile::restore(): roll back the DB transaction if the file is missing
[mediawiki.git] / t / maint / bom.t
blob19d74e3b080f82fce1e3838d937145360bc21ac4
1 #!/usr/bin/env perl
3 # This test detect Byte Order Mark (BOM). The char is sometime included at the
4 # top of files by some text editors to mark them as being UTF-8 encoded.
5 # They are not stripped by php 5.x and appear at the beginning of our content,
6 # You want them removed!
7 # See:
8 # http://www.fileformat.info/info/unicode/char/feff/index.htm
9 # http://bugzilla.wikimedia.org/show_bug.cgi?id=9954
11 use strict;
12 use warnings;
14 use Test::More;
16 use File::Find;
17 use File::Slurp qw< slurp >;
19 # Files for wich we want to check the BOM char ( 0xFE 0XFF )
20 my $ext = qr/(?:php|inc)/x ;
22 my $bomchar = qr/\xef\xbb\xbf/ ;
25 my @files;
27 find( sub{ push @files, $File::Find::name if -f && /\.$ext$/ }, '.' );
29 # Register our files with the test system
30 plan tests => scalar @files ;
32 for my $file (@files) {
33 my $content = slurp $file ;
34 if( $content =~ /$bomchar/ ) {
35 ok 0 => "$file got a Byte Order Mark";
36 } else {
37 ok 1 => "$file BOM less";