Bug 15774: (follow-up) Address QA issues
[koha.git] / t / 00-merge-conflict-markers.t
index 2e3b2fd..86f7fa5 100644 (file)
@@ -2,27 +2,27 @@
 #
 # 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 2 of the License, or (at your option) any later
-# version.
+# 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.
+# 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, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 
-use Test::More;
+use Test::More tests => 1;
 use File::Spec;
 use File::Find;
 use IO::File;
 
+my @failures;
 find({
     bydepth => 1,
     no_chdir => 1,
@@ -38,21 +38,15 @@ find({
 
         my $fh = IO::File->new($file, 'r');
         my $marker_found = 0;
-        my $line = 0;
-        while (<$fh>) {
-            $line++;
-            if (/^<<<<<</ or /^>>>>>>/) {
-                # could check for ^=====, but that's often used in text files
-                $marker_found = 1;
-                last;
-            }
+        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;
-        if ($marker_found) {
-            fail("$file contains merge conflict markers in line $line");
-        } else {
-            pass("$file has no merge conflict markers");
-        }
-    },
+        push @failures, $file if $marker_found;
+},
 }, File::Spec->curdir());
-done_testing();
+
+is( @failures, 0, 'Files should not contain merge markers' . ( @failures ? ( ' (' . join( ', ', @failures ) . ' )' ) : '' ) );