|
Lines 16-60
Link Here
|
| 16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
16 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
use Test::More; |
| 20 |
use Test::NoWarnings; |
20 |
use Test::NoWarnings; |
| 21 |
use Test::More tests => 2; |
|
|
| 22 |
use File::Spec; |
| 23 |
use File::Find; |
| 24 |
use IO::File; |
| 25 |
|
| 26 |
my @failures; |
| 27 |
find( |
| 28 |
{ |
| 29 |
bydepth => 1, |
| 30 |
no_chdir => 1, |
| 31 |
wanted => sub { |
| 32 |
my $file = $_; |
| 33 |
|
21 |
|
| 34 |
return if $file =~ /\.(ico|jpg|gif|ogg|pdf|png|psd|swf|zip|.*\~)$/; |
22 |
use Koha::Devel::Files; |
| 35 |
return unless -f $file; |
|
|
| 36 |
|
23 |
|
| 37 |
my @name_parts = File::Spec->splitpath($file); |
24 |
my $dev_files = Koha::Devel::Files->new( { context => 'full' } ); |
| 38 |
my %dirs = map { $_ => 1 } File::Spec->splitdir( $name_parts[1] ); |
25 |
my @files = $dev_files->ls_all_files( [qw(ico jpg gif ogg pdf png psd)] ); |
| 39 |
return if exists $dirs{'.git'}; |
|
|
| 40 |
|
26 |
|
| 41 |
my $fh = IO::File->new( $file, 'r' ); |
27 |
plan tests => scalar @files + 1; |
| 42 |
my $marker_found = 0; |
|
|
| 43 |
while ( my $line = <$fh> ) { |
| 44 |
|
28 |
|
| 45 |
# could check for ^=====, but that's often used in text files |
29 |
for my $file (@files) { |
| 46 |
$marker_found++ if $line =~ m|^<<<<<<|; |
30 |
my $has_conflicts; |
| 47 |
$marker_found++ if $line =~ m|^>>>>>>|; |
31 |
open my $fh, '<', $file or die "Cannot open $file: $!"; |
| 48 |
last if $marker_found; |
32 |
while ( my $line = <$fh> ) { |
| 49 |
} |
|
|
| 50 |
close $fh; |
| 51 |
push @failures, $file if $marker_found; |
| 52 |
}, |
| 53 |
}, |
| 54 |
File::Spec->curdir() |
| 55 |
); |
| 56 |
|
33 |
|
| 57 |
is( |
34 |
# Could check for ^=====, but that's often used in text files |
| 58 |
@failures, 0, |
35 |
if ( $line =~ /^<<<<<<<|^>>>>>>>/ ) { |
| 59 |
'Files should not contain merge markers' . ( @failures ? ( ' (' . join( ', ', @failures ) . ' )' ) : '' ) |
36 |
$has_conflicts = 1; |
| 60 |
); |
37 |
} |
|
|
38 |
} |
| 39 |
ok( !$has_conflicts, "$file should not contain merge conflict markers" ); |
| 40 |
close $fh; |
| 41 |
} |
| 61 |
- |
|
|