Koha/t/00-merge-conflict-markers.t
Jonathan Druart 0d03f143e2 Bug 19335: Fix 00-merge-conflict-markers.t when dockerised
This does not make sense, but fix a bug (why?)
Without this patch, the tests failed on po files:

[17:14:26] t/00-merge-conflict-markers.t .. Failed 1/1 subtests
Test Summary Report
-------------------
t/00-merge-conflict-markers.t (Wstat: 9 Tests: 0 Failed: 0)
  Non-zero wait status: 9
  Parse errors: Bad plan.  You planned 1 tests but ran 0.
Result: FAIL

Note that this is not related to bug 19227.

if the ^>>>>>> and ^<<<<<< matches are done on the same line, the test fail
As saw it failed on *-pref.po files
  misc/translator/po/kn-Knda-pref.po
  misc/translator/po/ja-Jpan-JP-pref.po
  misc/translator/po/nl-BE-pref.po
  misc/translator/po/sr-Cyrl-pref.po

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-09-19 09:00:49 -03:00

52 lines
1.7 KiB
Perl

# Copyright 2010 Galen Charlton
#
# This file is part of Koha.
#
# Koha is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# Koha is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Koha; if not, see <http://www.gnu.org/licenses>.
use Modern::Perl;
use Test::More tests => 1;
use File::Spec;
use File::Find;
use IO::File;
my @failures;
find({
bydepth => 1,
no_chdir => 1,
wanted => sub {
my $file = $_;
return if $file =~ /\.(ico|jpg|gif|ogg|pdf|png|psd|swf|zip|.*\~)$/;
return unless -f $file;
my @name_parts = File::Spec->splitpath($file);
my %dirs = map { $_ => 1 } File::Spec->splitdir($name_parts[1]);
return if exists $dirs{'.git'};
my $fh = IO::File->new($file, 'r');
my $marker_found = 0;
while (my $line = <$fh>) {
# could check for ^=====, but that's often used in text files
$marker_found++ if $line =~ m|^<<<<<<|;
$marker_found++ if $line =~ m|^>>>>>>|;
last if $marker_found;
}
close $fh;
push @failures, $file if $marker_found;
},
}, File::Spec->curdir());
is( @failures, 0, 'Files should not contain merge markers' . ( @failures ? ( ' (' . join( ', ', @failures ) . ' )' ) : '' ) );